MCPcopy Index your code
hub / github.com/cSploit/android / portRedirect

Method portRedirect

cSploit/src/org/csploit/android/tools/IPTables.java:53–73  ·  view source on GitHub ↗
(int from, int to, boolean cleanRules)

Source from the content-addressed store, hash-verified

51 }
52
53 public void portRedirect(int from, int to, boolean cleanRules){
54 Logger.debug("Redirecting traffic from port " + from + " to port " + to);
55
56 try{
57 if (cleanRules) {
58 // clear nat
59 super.run("-t nat -F");
60 // clear
61 super.run("-F");
62 // post route
63 super.run("-t nat -I POSTROUTING -s 0/0 -j MASQUERADE");
64 // accept all
65 super.run("-P FORWARD ACCEPT");
66 }
67 // add rule
68 super.run("-t nat -A PREROUTING -j DNAT -p tcp --dport " + from + " --to " + System.getNetwork().getLocalAddressAsString() + ":" + to);
69 }
70 catch(Exception e){
71 System.errorLogging(e);
72 }
73 }
74
75 public void undoPortRedirect(int from, int to){
76 Logger.debug("Undoing port redirection");

Callers 1

startMethod · 0.80

Calls 5

debugMethod · 0.95
getNetworkMethod · 0.95
errorLoggingMethod · 0.95
runMethod · 0.45

Tested by

no test coverage detected