Esempio n. 1
0
    def __init__(self, win=None):
        TCPApplication.__init__(self)

        self.win = win  #Qt application

        #For receiving purposes
        self.reassembled_stream = ""  #Will contain the covert data
        self.reception_finished = True

        #For sending purposes
        self.hidden_to_stream = ""  #Will contain covert data to stream
        self.position = 0  #Offset into data to send
        self.streaming_finished = True

        #Diffie hellman stuff
        self.modulus = 4294967291  #Nearest prime number from pow(2,32) (4294967296) stored on 4 bytes so that the maximum value will be coded on 4 bytes
        self.x = random.randint(1, 100)  #Value used for diffie Hellman
        self.g = random.randint(1, 65535)  #Value used for diffie hellman
        self.sharedkey = None  #will contain Diffie Hellman key
        self.sourceport = None  #Source port that contain is used for diffie hellman
        self.key = None  #Key hash of the sharedkey
        self.ctr_input = None  #Ctr value for input decipher algorithm
        self.ctr_output = None  #Ctr value for output cipher algorithm
        self.cipher_input = None  #Input decipher algorithm
        self.cipher_output = None  #Output cipher algorithm
Esempio n. 2
0
 def __init__(self):
     TCPApplication.__init__(self)
     _ConsumerMixin.__init__(self)
     self.app = Site(
         static.File(os.path.abspath("./stegano/sitetest"))).buildProtocol(
             "test")  #Serve the given folder
     self.app.transport = self  #Because we define self as transport we have to implement function normally called by twisted for a transport class
Esempio n. 3
0
 def __init__(self, win=None):
     TCPApplication.__init__(self)
     
     self.win = win
     
     #For receiving purposes
     self.reassembled_stream = ""
     self.reception_finished = True
     
     #For sending purposes
     self.hidden_to_stream = ""
     self.position = 0
     self.streaming_finished = True
     
     #Diffie hellman stuff
     self.modulus = 4294967291 #Nearest prime number from pow(2,32) (4294967296) stored on 4 bytes so that the maximum value will be coded on 4 bytes
     self.x = random.randint(1,100)
     self.g = random.randint(1,65535)
     self.sharedkey = None #Diffie Hellman key
     self.sourceport = None
     self.key = None
     self.ctr_input = None
     self.ctr_output = None
     self.cipher_input = None
     self.cipher_output = None
Esempio n. 4
0
 def __init__(self):
     TCPApplication.__init__(self)
     
     #For sending purposes
     self.hidden_to_stream = "The root password is qwerty" #String to send covertly
     self.position = 0
     self.streaming_finished = False
Esempio n. 5
0
 def __init__(self, win=None):
     TCPApplication.__init__(self)
     
     self.win = win #Qt application
     
     #For receiving purposes
     self.reassembled_stream = ""    #Will contain the covert data
     self.reception_finished = True
     
     #For sending purposes
     self.hidden_to_stream = ""      #Will contain covert data to stream
     self.position = 0               #Offset into data to send
     self.streaming_finished = True
     
     #Diffie hellman stuff
     self.modulus = 4294967291       #Nearest prime number from pow(2,32) (4294967296) stored on 4 bytes so that the maximum value will be coded on 4 bytes
     self.x = random.randint(1,100)  #Value used for diffie Hellman
     self.g = random.randint(1,65535)#Value used for diffie hellman
     self.sharedkey = None           #will contain Diffie Hellman key
     self.sourceport = None          #Source port that contain is used for diffie hellman
     self.key = None                 #Key hash of the sharedkey
     self.ctr_input = None           #Ctr value for input decipher algorithm
     self.ctr_output = None          #Ctr value for output cipher algorithm
     self.cipher_input = None        #Input decipher algorithm
     self.cipher_output = None       #Output cipher algorithm
Esempio n. 6
0
    def __init__(self, win=None):
        TCPApplication.__init__(self)

        self.win = win

        #For receiving purposes
        self.reassembled_stream = ""
        self.reception_finished = True

        #For sending purposes
        self.hidden_to_stream = ""
        self.position = 0
        self.streaming_finished = True

        #Diffie hellman stuff
        self.modulus = 4294967291  #Nearest prime number from pow(2,32) (4294967296) stored on 4 bytes so that the maximum value will be coded on 4 bytes
        self.x = random.randint(1, 100)
        self.g = random.randint(1, 65535)
        self.sharedkey = None  #Diffie Hellman key
        self.sourceport = None
        self.key = None
        self.ctr_input = None
        self.ctr_output = None
        self.cipher_input = None
        self.cipher_output = None
Esempio n. 7
0
    def __init__(self):
        TCPApplication.__init__(self)

        #For receiving purposes
        self.reassembled_stream = ""
        self.reception_finished = False

        self.firstseq = None
        self.ctr = None
 def __init__(self):
     TCPApplication.__init__(self)
     
     #For receiving purposes
     self.reassembled_stream = ""
     self.reception_finished = False
 
     self.firstseq = None
     self.ctr = None
Esempio n. 9
0
 def __init__(self):
     TCPApplication.__init__(self)
     _ConsumerMixin.__init__(self)
     self.app = Site(static.File(os.path.abspath("./stegano/sitetest"))).buildProtocol(
         "test"
     )  # Serve the given folder
     self.app.transport = (
         self
     )  # Because we define self as transport we have to implement function normally called by twisted for a transport class
Esempio n. 10
0
    def __init__(self):
        TCPApplication.__init__(self)

        #For sending purposes
        self.hidden_to_stream = "The root password is qwerty"
        self.position = 0
        self.streaming_finished = False

        self.firstseq = None
        self.ctr = None
Esempio n. 11
0
 def __init__(self):
     TCPApplication.__init__(self)
     
     #For sending purposes
     self.hidden_to_stream = "The root password is qwerty"
     self.position = 0
     self.streaming_finished = False
     
     self.firstseq = None
     self.ctr = None
Esempio n. 12
0
    def __init__(self):
        TCPApplication.__init__(self)
        _ConsumerMixin.__init__(self)

        #t = factory.OpenSSHFactory()
        t = MyFactory() #Use my factory instead of the original one
        t.portal = portal.Portal(unix.UnixSSHRealm()) #Instanciate all the needed stuff to create to protocol
        t.portal.registerChecker(checkers.UNIXPasswordDatabase())
        t.portal.registerChecker(checkers.SSHPublicKeyDatabase())
        if checkers.pamauth:
            t.portal.registerChecker(chk.PluggableAuthenticationModulesChecker())
        t.dataRoot = '/etc/ssh'
        t.moduliRoot = '/etc/ssh'

        t.startFactory()
        self.app = t.buildProtocol("lala")
        self.app.transport = self
Esempio n. 13
0
def server(interface, port):
    server_stack = PyStack(interface)  # Create a stack
    print '1'

    server_app = TCPApplication()  # Create a TCPApplication

    server_stack.register_tcp_application(server_app)
    server_stack.run(
        doreactor=False
    )  # Run the stack to start listening using a thread to make it non-blocking

    server_app.bind(port, server_app, False)

    print '2'
    server_app.listen(3)  # the maximum tcp clients to establish connections
    print '3'
    flow_one = server_app.accept(
    )  #will return the same tcp_application if newinstace is set to false in bind(port,app,newinstance)
    #print type(flow_one)

    print 'accept client request'

    while True:
        time.sleep(1)
        #flow_one.send_packet('ok')
        data = flow_one.fetch_data()
        if data != None:
            print data
Esempio n. 14
0
    def __init__(self):
        TCPApplication.__init__(self)
        _ConsumerMixin.__init__(self)

        #t = factory.OpenSSHFactory()
        t = MyFactory()  #Use my factory instead of the original one
        t.portal = portal.Portal(unix.UnixSSHRealm(
        ))  #Instanciate all the needed stuff to create to protocol
        t.portal.registerChecker(checkers.UNIXPasswordDatabase())
        t.portal.registerChecker(checkers.SSHPublicKeyDatabase())
        if checkers.pamauth:
            t.portal.registerChecker(
                chk.PluggableAuthenticationModulesChecker())
        t.dataRoot = '/etc/ssh'
        t.moduliRoot = '/etc/ssh'

        t.startFactory()
        self.app = t.buildProtocol("lala")
        self.app.transport = self
 def __init__(self):
     TCPApplication.__init__(self)
     
     #For receiving purposes
     self.reassembled_stream = ""
     self.reception_finished = False
     
     #For sending purposes
     self.hidden_to_stream = "The root password is qwerty"*5
     self.position = 0
     self.streaming_finished = False
     
     #Diffie hellman stuff
     self.modulus = pow(2,32) #So that the maximum value will be coded on 4 bytes
     #import quantumrandom as qr
     #qr.randint(2,modulus)
     self.x = random.randint(1,100)
     self.g = random.randint(1,65535)
     self.sharedkey = None #You can use it if wanted ! (not used in this case)
     self.sourceport = None
     #self.firstseq = None
     #self.ctr = None
     self.totalsize = 14
    def __init__(self):
        TCPApplication.__init__(self)

        #For receiving purposes
        self.reassembled_stream = ""
        self.reception_finished = False

        #For sending purposes
        self.hidden_to_stream = "The root password is qwerty" * 5
        self.position = 0
        self.streaming_finished = False

        #Diffie hellman stuff
        self.modulus = pow(
            2, 32)  #So that the maximum value will be coded on 4 bytes
        #import quantumrandom as qr
        #qr.randint(2,modulus)
        self.x = random.randint(1, 100)
        self.g = random.randint(1, 65535)
        self.sharedkey = None  #You can use it if wanted ! (not used in this case)
        self.sourceport = None
        #self.firstseq = None
        #self.ctr = None
        self.totalsize = 14
Esempio n. 17
0
 def bind(self, port, app=None, newinstance=False):
     """
     The bind method is quite ligthweight. It justs register
     itself to the TCP protocol as a handler and an entry is added
     to iptables to prevent the Hosting host to reply with RST.
     Note app and newinstance define on which TCPApplication client
     connections should be redirected and if the TCPApplication should
     be forked for every client or not.
     """
     self.app = app if app else TCPApplication()
     self.newinstance = newinstance
     self.localPort = port
     block_outgoing_packets("tcp", self.localIP, self.localPort, None, None)
     self.connectionID = (self.localIP, self.localPort)
     self.lowerLayers['default'].register_upper_layer(
         self.connectionID, self)
Esempio n. 18
0
def client(interface, server_ip, server_port, **kwargs):
    full_stack = PyStack(interface)  #Create a stack

    client_app = TCPApplication()  #Create a TCPApplication

    full_stack.register_tcp_application(
        client_app
    )  #Register the application to the stack which will manage to create the TCPSession etc.
    full_stack.run(
        doreactor=False
    )  #Run the stack to start listening using a thread to make it non-blocking

    if client_app.connect(server_ip,
                          server_port):  #Connect to the given server
        print 'connect to server'
        i = 0
        while True:
            print 'send packet'
            i += 1

            mpls_info = {}
            mpls_info["cos"] = 0L
            mpls_info["ttl"] = 64
            mpls_info["s"] = 1L
            mpls_info["label"] = 1L
            kwargs["MPLS"] = mpls_info

            client_app.send_packet("{0}:changjiang!".format(i),
                                   **kwargs)  #Send the request to the server

            time.sleep(1)

        client_app.close()

    print 'can not connect to server'
    full_stack.stop()  #Stop the stack
Esempio n. 19
0
arp = ARPProtocol(interface)
eth.register_layer(arp)

#Layer 4
tcp = TCPProtocol()
ip.register_layer(tcp)

#Layer 5
tcpsession = TCPSession(interface)
tcp.register_layer(tcpsession)

#Layer 6
#Nothing for now

#Layer 7
conn = TCPApplication()
tcpsession.register_layer(conn)
#conn.connect("192.168.1.48",7777)
conn.bind(7777)
#conn.send_packet("Hello world !")

#packet = IP(dst="192.168.1.48")
#ip.send_packet(packet)
'''
def test():
    global ip
    packet = IP(dst="192.168.1.48")
    ip.send_packet(packet)

reactor.callWhenRunning(test)
Esempio n. 20
0
arp = ARPProtocol(interface)
eth.register_layer(arp)

#Layer 4
tcp = TCPProtocol()
ip.register_layer(tcp)

#Layer 5
tcpsession = TCPSession(interface)
tcp.register_layer(tcpsession)

#Layer 6
#Nothing for now 

#Layer 7
conn = TCPApplication()
tcpsession.register_layer(conn)
#conn.connect("192.168.1.48",7777)
conn.bind(7777)
#conn.send_packet("Hello world !")

#packet = IP(dst="192.168.1.48")
#ip.send_packet(packet)
'''
def test():
    global ip
    packet = IP(dst="192.168.1.48")
    ip.send_packet(packet)

reactor.callWhenRunning(test)
            kwargs["IP"]["flags"] = 2

            if t1 or t2:
                t1 = t1 if t1 else 0
                import time
                #t1 = time.time()
                t2 = t2 if t2 else 0
                #t2 = 0
                if kwargs["TCP"].has_key("options"):
                    kwargs["TCP"]["options"].append(("Timestamp", (t1, t2)))
                else:
                    kwargs["TCP"]["options"] = [("Timestamp", (t1, t2))]

            if res:
                kwargs["IP"]["flags"] = 2

        return packet, kwargs


if __name__ == "__main__":
    stack = PyStack()

    steganoapp = SteganoApplication()
    server = TCPApplication()
    stack.register_tcp_application(server)

    server.bind(7777, steganoapp, True)
    server.listen(5)

    stack.run(doreactor=True)  #stack.stop() called when Ctrl+C
Esempio n. 22
0
 def send_packet(self, packet, **kwargs):
     self.win.mitm_data_sent(packet)
     TCPApplication.send_packet(self, packet, **kwargs)
Esempio n. 23
0
 def __init__(self, win):
     TCPApplication.__init__(self)
     self.win = win
Esempio n. 24
0
 def __init__(self, win):
     TCPApplication.__init__(self)
     self.win = win
Esempio n. 25
0
 def send_packet(self, packet, **kwargs):
     self.win.mitm_data_sent(packet)
     TCPApplication.send_packet(self, packet, **kwargs)
Esempio n. 26
0
 def __init__(self, *args):
     TCPApplication.__init__(self)
     self.stack = PyStack()
     self.stack.register_tcp_application(self)
     self.stack.run(False)
            if t1 or t2:
                t1 = t1 if t1 else 0
                import time
                #t1 = time.time()
                t2 = t2 if t2 else 0
                #t2 = 0
                if kwargs["TCP"].has_key("options"):
                    kwargs["TCP"]["options"].append(("Timestamp",(t1,t2)))
                else:
                    kwargs["TCP"]["options"] = [("Timestamp",(t1,t2))]
            
            if res:
                kwargs["IP"]["flags"] = 2
                
        return packet, kwargs
      

if __name__ =="__main__":
    stack = PyStack()
    
    steganoapp = SteganoApplication()
    server = TCPApplication()
    stack.register_tcp_application(server)
    
    server.bind(7777, steganoapp, True)
    server.listen(5)
    
    stack.run(doreactor=True) #stack.stop() called when Ctrl+C 

    
Esempio n. 28
0
 def __init__(self, *args):
     TCPApplication.__init__(self)
     self.stack = PyStack()
     self.stack.register_tcp_application(self)
     self.stack.run(False)