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
Author: Robin David License: GNU GPLv3 Repo: https://github.com/RobinDavid Copyright (c) 2012 Robin David PyStack is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version http://www.gnu.org/licenses/. ''' import pystack.pystack_socket #Import the pystack socket module import sys sys.modules["socket_original"] = sys.modules["socket"] #Replace the genuine socket module by ours in sys sys.modules["socket"] = pystack.pystack_socket #print sys.modules["socket"] from test_client import Client #Import a simple client that use socket normally (nothing has been changed inside) c =Client() c.run() #The run launch the client that will use Pystack instead of socket without knowing it from pystack.pystack import PyStack s = PyStack() #Retrieve the pystack instance to stop it s.stop() #Call stop (so that wall rules in iptables will be removed etc ..(just in case)) sys.modules["socket"] = sys.modules["socket_original"] #Put back the original socket in sys (useless because the script ends just after) sys.modules.pop("socket_original") #print(sys.modules["socket"])
app.setApplicationName("SteganoChat") win = ChatWindow() stack = PyStack() stack.run(doreactor=False) steganoapp = SteganoApplication(win) #--Server-- #server = TCPApplication() #stack.register_tcp_application(server) #---------- #--Client-- stack.register_tcp_application(steganoapp) #---------- win.set_tcpapp(steganoapp) steganoapp.run() #--Server-- #server.bind(7777, steganoapp, True) #server.listen(1) # #---------- #--Client-- steganoapp.connect("192.168.1.38", 7777) #---------- app.exec_() stack.stop()
if __name__ == "__main__": stack = PyStack() stack.run(doreactor=False) steganoclient = SteganoApplication() stack.register_tcp_application(steganoclient) if steganoclient.connect("192.168.1.37", 7777): steganoclient.send_packet("Hello") steganoclient.send_packet("my") steganoclient.send_packet("name") steganoclient.send_packet("is") steganoclient.send_packet("XXXX") steganoclient.send_packet("this") steganoclient.send_packet("is") steganoclient.send_packet("a") steganoclient.send_packet("test") steganoclient.send_packet("of") steganoclient.send_packet("steganography") steganoclient.send_packet("and") steganoclient.send_packet("that's") steganoclient.send_packet("it.") import time time.sleep(3) steganoclient.close() stack.stop()
Repo: https://github.com/RobinDavid Copyright (c) 2012 Robin David PyStack is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version http://www.gnu.org/licenses/. ''' import pystack.pystack_socket #Import the pystack socket module import sys sys.modules["socket_original"] = sys.modules[ "socket"] #Replace the genuine socket module by ours in sys sys.modules["socket"] = pystack.pystack_socket #print sys.modules["socket"] from test_client import Client #Import a simple client that use socket normally (nothing has been changed inside) c = Client() c.run( ) #The run launch the client that will use Pystack instead of socket without knowing it from pystack.pystack import PyStack s = PyStack() #Retrieve the pystack instance to stop it s.stop( ) #Call stop (so that wall rules in iptables will be removed etc ..(just in case)) sys.modules["socket"] = sys.modules[ "socket_original"] #Put back the original socket in sys (useless because the script ends just after) sys.modules.pop("socket_original") #print(sys.modules["socket"])