Example #1
0
def server_side():
    global server
    server = ara.Web(host=IP_ADDR, port=PORT_NUMBER, verbose=1)
    server.tasks = []
    server.init()

    def read_keyboard_info(server):
        if server.tasks:
            return server.tasks.pop(0)
        else:
            None

    '''
	def send_keyboard_info(server): # send mouse info to server
		global last_pos
		MAX_KEY_CHUNK_SIZE = 30 # one key is defined by a group of n key, up to MAX_KEY_CHUNK_SIZE times the same key
		while True:
			key_strokes = get_key_strokes()
			if key_strokes:

				chunk_size = 0
				last_key_stroke = key_strokes[0]
				server.tasks.append(b'<KEY-PRESS %i>' % last_key_stroke)
				print('counted {} times {} key'.format(key_strokes.count(last_key_stroke), last_key_stroke))

				for key in key_strokes:
					if key == last_key_stroke:
						chunk_size += 1
					else:
						server.tasks.append(b'<KEY-PRESS %i>' % key)
						last_key_stroke = key
						chunk_size = 0
					if chunk_size >=  MAX_KEY_CHUNK_SIZE: # >= because if the next one is not last_key_stroke, the ky won't repeat. So, the key repeats only if chunk_size > MAX_KEY_CHUNK_SIZE (next iteration, if key == last_key_stroke)
						chunk_size = 0
				ara.time.sleep(.01)
	'''

    def send_keyboard_info():
        with keyboard.Listener(on_press=on_press,
                               on_release=on_release) as listener:
            listener.join()

    thread = ara.Thread(
        target=lambda: server.start(read_f=lambda: read_keyboard_info(server)))
    thread2 = ara.Thread(target=send_keyboard_info)

    thread.start()
    thread2.start()

    input('stop')

    os.system('taskkill /f /pid {}'.format(ara.get_pid()))
Example #2
0
def client_side():
    client = ara.Spider(ip=IP_ADDR, port=PORT_NUMBER, verbose=1)
    client.connect()
    thread = ara.Thread(target=client.loop2)
    thread.start()

    thread2 = ara.Thread(target=sync_keyboard_client, args=(client, ))
    thread2.start()

    input('stop')

    thread.join()
    thread2.join()

    os.system('taskkill /f /pid {}'.format(ara.get_pid()))
Example #3
0
def server_side():
    server = ara.Web(IP_ADDR, PORT_NUMBER, verbose=0)
    server.tasks = []
    server.init()

    global last_pos
    last_pos = get_mouse_pos()

    def read_mouse_info(server):
        if server.tasks:
            return server.tasks.pop(0)
        else:
            None

    def send_mouse_info(server):  # send mouse info to server
        global last_pos
        WAIT_TIME = int(sys.argv[-2]) / 1000
        while True:
            cur_pos = get_mouse_pos()
            if last_pos != cur_pos:
                mapped_pos = map_mouse_pos(cur_pos)
                server.tasks.append(b'<MOUSE-POS %i-%i>' %
                                    (mapped_pos[0], mapped_pos[1]))
                last_pos = cur_pos[:]
                ara.time.sleep(WAIT_TIME)
            left_state = win32api.GetKeyState(0x01)
            right_state = win32api.GetKeyState(0x02)
            if left_state not in [0, 1]:
                server.tasks.append(b'<MOUSE-PRESS 1>')
            if right_state not in [0, 1]:
                server.tasks.append(b'<MOUSE-PRESS 2>')

    thread = ara.Thread(
        target=lambda: server.start(read_f=lambda: read_mouse_info(server)))
    thread2 = ara.Thread(target=send_mouse_info, args=(server, ))

    thread.start()
    thread2.start()

    input('stop')

    os.system('taskkill /f /pid {}'.format(ara.get_pid()))
Example #4
0
                    metavar='output-file',
                    type=str,
                    help='output file',
                    default='output.txt')

parser.add_argument('-v',
                    '--verbose',
                    metavar='verbose',
                    type=int,
                    help='verbose [0, 1]',
                    default=DEFAULT_VERBOSE)

args = vars(parser.parse_args())
print(args)

open('pid.txt', 'w').write(str(arachnoid.get_pid()))

if args['r__role'] == 'server':
    server = arachnoid.Web(host=args['ip_address'],
                           port=args['port'],
                           max_clients=args['max_clients'],
                           max_buffer_size=args['max_buffer_size'],
                           server_in_file=args['input_file'],
                           server_out_file=args['output_file'],
                           verbose=args['verbose'])
    server.init()
    if args['verbose']: print('Starting 🕸️ Server')
    server.start(server.df_read_f)
    server.close()

elif args['r__role'] == 'client':
Example #5
0
# Keyboard Synchronization
import arachnoid as ara
#import win32api, win32con
from pynput import keyboard
import os, sys

print('PID: {}'.format(ara.get_pid()))

IP_ADDR = '192.168.1.94'  #'43.33'
PORT_NUMBER = 5555
#KB_LAYOUT = win32api.GetKeyboardLayout()
'''
def get_key_strokes(from_=0, to=250):
	return list(filter(lambda key: win32api.GetAsyncKeyState(key), range(from_, to)))

def simple_key_press(key):
	win32api.keybd_event(key, 0, 0, 0)
	ara.time.sleep(.05)
	win32api.keybd_event(key, 0, win32con.KEYEVENTF_KEYUP, 0)

def hold_key_press(keys):
	# press keys in order (e.g. control + shift + a)
	for key in keys:
		win32api.keybd_event(key, 0, 0, 0)
		ara.time.sleep(.05)
	# release keys in reverse order
	for key in keys[::-1]:
		win32api.keybd_event(key, 0, win32con.KEYEVENTF_KEYUP, 0)
		ara.time.sleep(.1)

def change_keyboard_layout(layout):
Example #6
0
import arachnoid as ara
import interpreter as inter

IP_ADDR = '192.168.1.94'
PORT_NUMBER = 1234

for arg in ara.sys.argv:
    if arg.startswith('ip='):
        IP_ADDR = arg[3:]
        print('ip: {}'.format(IP_ADDR))
    elif arg.startswith('port='):
        PORT_NUMBER = int(arg[5:])
        print('port: {}'.format(PORT_NUMBER))

PID = ara.get_pid()
open(ara.os.path.join(ara.ROOT_DIR, 'shell v2 pid.txt'), 'w').write(str(PID))
print('PID: {}'.format(PID))


def main():
    client = ara.Spider(ip=IP_ADDR,
                        port=PORT_NUMBER,
                        client_in_file='client in v2.txt',
                        verbose=inter.ENV_VARS['VERBOSE'])
    client.connect()
    thread = ara.Thread(target=client.loop2)
    thread.start()

    #thread2 = ara.Thread(target=lambda : inter.message_printer(file_path=ara.os.path.join(ara.ROOT_DIR, 'client in v2.txt')))
    #thread2.start()