int main(int argc, char* argv[]) { InitModuleObjects(); EnableSEHtoExceptionMapping(); if (argc<6) { usage(); return 0; } try { const char *filename = argv[1]; Owned<IDaliCapabilityCreator> cc = createDaliCapabilityCreator(); cc->setSystemID(argv[2]); cc->setServerPassword(argv[3]); for (unsigned i=4;i<argc;i++) { const char *cmd = argv[i++]; if (i==argc) break; const char *param = argv[i]; if (stricmp(cmd,"THORWIDTH")==0) { cc->setLimit(DCR_ThorSlave,atoi(param)); } else if (stricmp(cmd,"DALINODE")==0) { StringBuffer mac; if (strchr(param,'.')) { // must be ip IpAddress ip; ip.set(param); if (!getMAC(ip,mac)) { printf("ERROR: could mot get MAC address for %s\n",param); return 1; } } else mac.append(param); cc->addCapability(DCR_DaliServer,mac.str()); } else { printf("ERROR: unknown command %s\n",cmd); return 1; } } StringBuffer results; cc->save(results); Owned<IFile> ifile = createIFile(filename); Owned<IFileIO> ifileio = ifile->open(IFOcreate); ifileio->write(0,results.length(),results.str()); printf("Dali Capabilities sucessfully exported to %s\n", filename); } catch (IException *e) { EXCLOG(e); e->Release(); } releaseAtoms(); return 0; }
// Build connmanctl command from network settings void update_network(int dhcp, char* address, char* netmask, char* gateway) { DIR* dir; struct dirent* dp; char sbuff[360], mac_address[30]; char name[12] = "ethernet_"; sprintf(mac_address, "ethernet_%s_cable", getMAC(0)); name[9] = 0; memset(sbuff, 0, 360); dir = opendir("/var/lib/connman/"); while ((dp = readdir(dir)) != NULL) { if (strstr(dp->d_name, name) != NULL && strcmp(dp->d_name, mac_address) == 0) { // formulate command if (dhcp) { sprintf(sbuff, "connmanctl config %s --ipv4 dhcp", dp->d_name); } else { sprintf(sbuff, "connmanctl config %s --ipv4 manual %s %s %s", dp->d_name, address, netmask, gateway); } closedir(dir); logger_remotem("update_network: %s", sbuff); system(sbuff); system("sync; sync"); int i; for (i = 0; i < 5; i++) { sleep(1); } return; } } }
// 12. GET_INFO static void proc_cmd_get_info(struct mg_connection* conn, const struct mg_request_info* request_info) { logger_remotem("GET_INFO from client: %s, version %s, ID: %s", ip2s(request_info->remote_ip), getVersion(), DVR_ID); unsigned long* drive_info = getDriveInfo(DataPath); if (DVR_ID == NULL) { logger_info("No valid ID found wait for next call: %s", DVR_ID); mg_printf(conn, "errno=51010\r\n"); return; } char tb[40]; time_t now = time(NULL); struct tm tmi; strftime(tb, 20, "%Y%m%d_%H%M%S", localtime_r(&now, &tmi)); mg_printf(conn, "HTTP/1.0 200 OK\r\n\n" "serial=%s\r\n" "version=%s\r\n" "dvr_status=%s\r\n" "battery_status=%s\r\n" "product_code=FBBW1\r\n" "filesystem_size=%lu\r\n" "free_blocks=%lu\r\n" "fg_video=%d\r\n" "mac_address=%s\r\n" "mainboard=%s\r\n" "date_time=%s\r\n" "assignable=%s\r\n" "dvr_name=%s\r\n" "errno=0\r\n", DVR_ID, getVersion(), downloading_status, get_battery_level_string(), drive_info[0], drive_info[1], getVideoCount(DataPath), getMAC(1), get_hw_version(), tb, get_assignable(), get_dvr_name()); }
int main(int argc, char *argv[]) { // techrypt < input file > [-d < IP-addr:port >][-l ] if((argc==4) && strncmp(*(argv+2),"-d",2)==0) //for sending file over network { char IP[16]; char port[6]; memset(IP,0,16); memset(port,0,6); char *token=NULL; int i=0; if (strchr(*(argv+3),':')) //check if port number has been provided { int sockfd = 0; struct sockaddr_in serv_addr; FILE *f=fopen(*(argv+1),"r"); int c=0,index=0,fLen=getFileSize(f); char fileContents[fLen]; memset(fileContents,0,fLen); while((c=fgetc(f)) && !feof(f)) *(fileContents+index++)=c; //read file's contents into a buffer : 'fileContents' fclose(f); char passphrase[30]; printf("Password: "******"\nCould not create socket!\n"); return 1; } memset(&serv_addr, '0', sizeof(serv_addr)); serv_addr.sin_family = AF_INET; char IPAddress[22]; memset(IPAddress,0,22); strncpy(IPAddress,*(argv+3),21); for(token=strtok(*(argv+3),":");token!=NULL;token=strtok(NULL,":"),i++) { if (i==0) strncpy(IP,token,15); //get IP else strncpy(port,token,5); //get port number } serv_addr.sin_port = htons(atoi(port)); if(inet_pton(AF_INET, IP, &serv_addr.sin_addr)<=0) { printf("\n'inet_pton' Error!\n"); return 1; } if( connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { printf("\nConnection Failed!\n"); return 1; } printf("Transmitting to %s.\n",IPAddress); char fNameLen[20]; memset(fNameLen,0,20); sprintf(fNameLen,"%zu",strlen(*(argv+1))); //store file-name's length in variable 'fNameLen' char fLength[20]; memset(fLength,0,20); sprintf(fLength,"%d",ctxtLen+64); //store file's length in variable 'fLength' char padASCII[20]; memset(padASCII,0,20); sprintf(padASCII,"%d",pad); //store pad in variable 'padASCII' char padLen[20]; memset(padLen,0,20); sprintf(padLen,"%zu",strlen(padASCII)); //store pad's length in variable 'padLen' write(sockfd,fNameLen,strlen(fNameLen)); //send file name's length write(sockfd,*(argv+1),strlen(*(argv+1))); //send file's name write(sockfd,padLen,strlen(padLen)); //send pad length write(sockfd,"-",1); // send delimiter write(sockfd,padASCII,strlen(padASCII)); //send pad write(sockfd,fLength,strlen(fLength)); // send encrypted file's length write(sockfd,ctxt,ctxtLen); // send encrypted file's contents write(sockfd,mac,64); // send mac printf("Successfully sent.\n"); if(ctxt) free(ctxt); return 0; } else return 1; } else { printf("Error incurred during key generation!\n"); return 1; } } else { printf("Invalid address!\n"); return 1; } } if((argc==3) && strncmp(*(argv+2),"-l",2)==0) //for 'local' operation { char newFileName[strlen(*(argv+1))+3]; memset(newFileName,0,strlen(*(argv+1))+3); strcpy(newFileName,*(argv+1)); strcat(newFileName,".gt"); if(!file_exists(newFileName)) // if file with name 'newFileName' exists, return 33 { FILE *f=fopen(*(argv+1),"r"); int c=0,index=0,fLen=getFileSize(f); char fileContents[fLen]; memset(fileContents,0,fLen); while((c=fgetc(f)) && !feof(f)) *(fileContents+index++)=c; // read the contents of file (to be encrypted) fclose(f); char passphrase[30]; printf("Password: "******"%d",pad); //store pad's value in variable "pad" FILE *f=fopen(newFileName,"w"); fprintf(f,"%zu",strlen(padASCII));// write padLen fprintf(f,"%c",'-'); // write delimiter fprintf(f,"%d",pad); // write pad index=0; while(index<ctxtLen) fputc(*(ctxt+index++),f); // write encrypted file's contents index=0; while(index<64) fputc(*(mac+index++),f); // write mac fclose(f); if(ctxt) free(ctxt); return 0; } else return 1; } else return 1; } else return 33; } else { printf("Invalid option(s) given!\n"); return 1; } }
int _tmain(int argc, _TCHAR* argv[]) { char mac[1024] = { 0 }; getMAC(mac); return 0; }
void CLoginHelper::DoLogin() { SaveUserName(); LoadComputerToken(); //CheckingCRC(); //char msg[512] = {0}; //sprintf(msg,"api_login.php?userfuckingshit=%s&passwordfuckyou=%s&serverkey=4077-ASWE-ALLR-ASSS-KEYS&computerid=%d&miniacrc=0&warguardcrc=0",username,passwd,hardwareid); //r3dOutToLog("%s\n",msg); CWOBackendReq req("api_login.aspx"); // api_Login.aspx req.AddParam("userfuckingshit", username); req.AddParam("passwordfuckyou", passwd); req.AddParam("serverkey", "4077-ASWE-ALLR-ASSS-KEYS"); req.AddParam("computerid", hardwareid); req.AddParam("miniacrc", 0); req.AddParam("warguardcrc", 0); req.AddParam("mac", getMAC()); if(!req.Issue()) { r3dOutToLog("Login FAILED, code: %d\n", req.resultCode_); loginAnswerCode = ANS_Error; return; } int n = sscanf(req.bodyStr_, "%d %d %d", &CustomerID, &SessionID, &AccountStatus); if(n != 3) { r3dError("Login: bad answer\n"); return; } if(AccountStatus == 999) { loginAnswerCode = ANS_Deleted; return; } if(CustomerID == 0) { loginAnswerCode = ANS_BadPassword; return; } if(AccountStatus == 100) loginAnswerCode = ANS_Logged; else if(AccountStatus == 70) loginAnswerCode = ANS_GameActive; else if(AccountStatus == 200) loginAnswerCode = ANS_Banned; else if(AccountStatus == 201) loginAnswerCode = ANS_Frozen; else if(AccountStatus == 300) loginAnswerCode = ANS_TimeExpired; else loginAnswerCode = ANS_Unknown; return; }