Update to DNS CLient
parent
8418713e9c
commit
eb0912d32b
|
@ -10,6 +10,7 @@ import base64
|
|||
import re
|
||||
import socket
|
||||
import sys
|
||||
from common import helpers
|
||||
from scapy.all import *
|
||||
|
||||
|
||||
|
@ -17,7 +18,7 @@ class Client:
|
|||
|
||||
def __init__(self, cli_object):
|
||||
self.protocol = "dns"
|
||||
self.length = 62
|
||||
self.length = 35
|
||||
self.remote_server = cli_object.ip
|
||||
|
||||
def transmit(self, data_to_transmit):
|
||||
|
@ -26,22 +27,20 @@ class Client:
|
|||
packet_number = 1
|
||||
|
||||
# Determine if sending via IP or domain name
|
||||
if self.validate_ip(self.remote_server):
|
||||
if helpers.validate_ip(self.remote_server):
|
||||
final_destination = self.remote_server
|
||||
else:
|
||||
print "[*] Resolving IP of domain..."
|
||||
final_destination = socket.gethostbyname(self.remote_server)
|
||||
|
||||
print "[*] Splitting data into chunks that fit in DNS packets...."
|
||||
|
||||
while (byte_reader < len(data_to_transmit) + 35):
|
||||
encoded_data = base64.b64encode(data_to_transmit[byte_reader:byte_reader + 35])
|
||||
while (byte_reader < len(data_to_transmit) + self.length):
|
||||
encoded_data = base64.b64encode(data_to_transmit[byte_reader:byte_reader + self.length])
|
||||
|
||||
# calcalate total packets
|
||||
if ((len(data_to_transmit) % 35) == 0):
|
||||
total_packets = len(data_to_transmit) / 35
|
||||
if ((len(data_to_transmit) % self.length) == 0):
|
||||
total_packets = len(data_to_transmit) / self.length
|
||||
else:
|
||||
total_packets = (len(data_to_transmit) / 35) + 1
|
||||
total_packets = (len(data_to_transmit) / self.length) + 1
|
||||
|
||||
print "[*] Packet Number/Total Packets: " + str(packet_number) + "/" + str(total_packets)
|
||||
|
||||
|
@ -57,20 +56,7 @@ class Client:
|
|||
sys.exit()
|
||||
|
||||
# Increment counters
|
||||
byte_reader += 35
|
||||
byte_reader += self.length
|
||||
packet_number += 1
|
||||
|
||||
return
|
||||
|
||||
def validate_ip(self, val_ip):
|
||||
# This came from (Mult-line link for pep8 compliance)
|
||||
# http://python-iptools.googlecode.com/svn-history/r4
|
||||
# /trunk/iptools/__init__.py
|
||||
ip_re = re.compile(r'^(\d{1,3}\.){0,3}\d{1,3}$')
|
||||
if ip_re.match(val_ip):
|
||||
quads = (int(q) for q in val_ip.split('.'))
|
||||
for q in quads:
|
||||
if q > 255:
|
||||
return False
|
||||
return True
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue