Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.mau.antiarp.service;
- import android.app.Activity;
- import android.app.Notification;
- import android.app.NotificationManager;
- import android.app.PendingIntent;
- import android.app.Service;
- import android.content.Intent;
- import android.net.wifi.WifiManager;
- import android.os.IBinder;
- import android.os.Message;
- import android.os.Messenger;
- import android.os.RemoteException;
- import android.text.format.Formatter;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.concurrent.TimeoutException;
- import me.mau.jniexec.JNIExec;
- import me.mau.p004a.C0092c;
- import me.mau.antiarp.R;
- import me.mau.antiarp.AntiARP;
- public class WFKService extends Service {
- public ArrayList f499a = new ArrayList();
- public boolean f500b = false;
- final Messenger f501c = new Messenger(new C0122g(this));
- private NotificationManager f502d;
- private int f503e = 31337;
- private ArrayList f504f = new ArrayList();
- private Activity f505g = null;
- private JNIExec f506h = null;
- private JNIExec f507i = null;
- private int f508j = -1;
- private C0124i f509k = null;
- private void m450a(int i, Object obj) {
- for (int size = this.f504f.size() - 1; size >= 0; size--) {
- try {
- ((Messenger) this.f504f.get(size)).send(Message.obtain(null, i, obj));
- } catch (RemoteException e) {
- this.f504f.remove(size);
- }
- }
- }
- private void m451a(String str) {
- C0092c.m370a("error=" + str);
- if (this.f509k != null) {
- this.f509k.f533a = true;
- this.f509k.interrupt();
- try {
- this.f509k.join();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- JNIExec.m371a("iptables -D FORWARD -j ACCEPT && iptables -t nat -D POSTROUTING -j MASQUERADE");
- this.f499a.clear();
- m450a(4, (Object) str);
- stopSelf();
- }
- static void m453a(WFKService wFKService, Runnable runnable) {
- if (wFKService.f505g == null) {
- runnable.run();
- } else {
- wFKService.f505g.runOnUiThread(runnable);
- }
- }
- static void m455a(WFKService wFKService, C0116a c0116a) {
- C0092c.m370a("---");
- wFKService.m457a(c0116a);
- wFKService.f506h.m378b("1" + c0116a.f510a + "\n");
- c0116a.f514e |= 1;
- wFKService.m450a(107, (Object) c0116a);
- }
- static void m456a(WFKService wFKService, boolean z) {
- C0092c.m370a("---");
- wFKService.f506h.m378b(z ? "r\n" : "R\n");
- }
- private void m457a(C0116a c0116a) {
- this.f507i.m378b("iptables -D FORWARD -s " + c0116a.f510a + " -p tcp -j REJECT --reject-with tcp-reset\n");
- this.f507i.m378b("iptables -D FORWARD -s " + c0116a.f510a + " -p udp -j REJECT --reject-with icmp-port-unreachable\n");
- }
- private String m458b(String str) {
- String str2 = null;
- File file = new File(getApplicationContext().getFilesDir().getPath() + "/devices/" + str);
- if (file.exists()) {
- try {
- BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
- str2 = bufferedReader.readLine();
- bufferedReader.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e2) {
- e2.printStackTrace();
- }
- }
- return str2;
- }
- static C0116a m459b(WFKService wFKService, String str) {
- Iterator it = wFKService.f499a.iterator();
- while (it.hasNext()) {
- C0116a c0116a = (C0116a) it.next();
- if (c0116a.f510a.equals(str)) {
- return c0116a;
- }
- }
- return null;
- }
- static void m460b(WFKService wFKService) {
- Notification notification = new Notification(R.drawable.icon, "AntiARP", System.currentTimeMillis());
- notification.setLatestEventInfo(wFKService, "AntiARP", "is running", PendingIntent.getActivity(wFKService, 0, new Intent(wFKService, AntiARP.class), 0));
- notification.flags |= 2;
- wFKService.startForeground(wFKService.f503e, notification);
- }
- static void m461b(WFKService wFKService, C0116a c0116a) {
- C0092c.m370a("---");
- wFKService.f506h.m378b("0" + c0116a.f510a + "\n");
- wFKService.m457a(c0116a);
- c0116a.f514e = 0;
- wFKService.m450a(107, (Object) c0116a);
- }
- static void m463c(WFKService wFKService) {
- String str = wFKService.getApplicationContext().getFilesDir().getPath() + "/wfk";
- C0092c.m370a("begin");
- if (wFKService.f509k == null) {
- if (!new File(str).exists()) {
- wFKService.m451a("Binary file not present!");
- }
- JNIExec.m371a("chmod 777 " + str);
- JNIExec.m371a("iptables -F; iptables -X && iptables -t nat -F; iptables -t nat -Xiptables -P FORWARD ACCEPT && iptables -I FORWARD -j ACCEPT && iptables -t nat -I POSTROUTING -j MASQUERADE &&echo 1 > /proc/sys/net/ipv4/ip_forward");
- wFKService.f506h = new JNIExec(new C0120e(wFKService));
- wFKService.f507i = new JNIExec(new C0121f(wFKService));
- wFKService.f506h.m379c(str + " -g " + Formatter.formatIpAddress(((WifiManager) wFKService.getApplicationContext().getSystemService("wifi")).getDhcpInfo().gateway) + " " + C0092c.m366a(wFKService.getApplicationContext()));
- String str2 = null;
- while (true) {
- try {
- str = wFKService.f506h.m376a(0);
- } catch (TimeoutException e) {
- e.printStackTrace();
- str = str2;
- }
- if (str == null || !str.startsWith("ERROR")) {
- C0092c.m370a("read: " + str);
- if (str != null && !str.contains("PID")) {
- str2 = str;
- } else if (str != null) {
- wFKService.m451a("Unable to start service, do you have root?");
- } else {
- wFKService.f508j = Integer.parseInt(str.split("PID ")[1]);
- wFKService.f509k = new C0124i(wFKService);
- wFKService.f509k.start();
- return;
- }
- }
- wFKService.m451a(str.substring(8));
- return;
- }
- if (str != null) {
- wFKService.f508j = Integer.parseInt(str.split("PID ")[1]);
- wFKService.f509k = new C0124i(wFKService);
- wFKService.f509k.start();
- return;
- }
- wFKService.m451a("Unable to start service, do you have root?");
- }
- }
- static void m464c(WFKService wFKService, C0116a c0116a) {
- C0092c.m370a("---");
- wFKService.f507i.m378b("iptables -I FORWARD -s " + c0116a.f510a + " -p tcp -j REJECT --reject-with tcp-reset\n");
- wFKService.f507i.m378b("iptables -I FORWARD -s " + c0116a.f510a + " -p udp -j REJECT --reject-with icmp-port-unreachable\n");
- c0116a.f514e |= 2;
- wFKService.m450a(107, (Object) c0116a);
- }
- static void m466d(WFKService wFKService, C0116a c0116a) {
- C0092c.m370a("---");
- int i = 3;
- while (true) {
- int i2 = i - 1;
- if (i > 0) {
- wFKService.m457a(c0116a);
- i = i2;
- } else {
- c0116a.f514e &= -3;
- wFKService.m450a(107, (Object) c0116a);
- return;
- }
- }
- }
- public IBinder onBind(Intent intent) {
- C0092c.m370a("---");
- return this.f501c.getBinder();
- }
- public void onCreate() {
- this.f502d = (NotificationManager) getSystemService("notification");
- }
- public void onDestroy() {
- C0092c.m370a("---");
- stopForeground(true);
- this.f502d.cancel(this.f503e);
- C0092c.m367a(this, "AntiARP service stopped");
- }
- public int onStartCommand(Intent intent, int i, int i2) {
- return 2;
- }
- public boolean onUnbind(Intent intent) {
- C0092c.m370a("---");
- this.f505g = null;
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement