My Brute Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.



 
HomeSearchLatest imagesRegisterLog in
Registration DOES NOT need an email verification.
Welcome to the biggest MyBrute forum on the internet.
Look at the sections' stickies: you'll find there everything you need to know about the game!

 

 C++ Reconnect

Go down 
5 posters
AuthorMessage
Maccaz
Forum Mod
Forum Mod
Maccaz


Posts : 870
Join date : 2009-04-23
Location : Adelaide, Australia

C++ Reconnect Empty
PostSubject: C++ Reconnect   C++ Reconnect Icon_minitimeSat 01 Aug 2009, 03:07

Well I got a friend to make this for me, as he is fluent in C++. Usually I had to go through my webbrowser, go to my ip address, type in the user and password, click restart and then submit,

Now it bypasses all that without even having to open a browser.

It uses httpwinsock and the live http headers I collected by going to the webpage that actually restarts my modem.

If anyone understands this, they can probably change it to their own modem if they need to restart it the same way as me.

Code:

#include <WinSock2.h>
#include <Windows.h>
#include <iostream>
#include <tchar.h>
#include <strsafe.h>

void ShowErrAndExit(PTSTR lpszFunction)
{
   LPVOID lpMsgBuf;
   LPVOID lpDisplayBuf;
   DWORD dw = GetLastError();

   FormatMessage(
      FORMAT_MESSAGE_ALLOCATE_BUFFER |
      FORMAT_MESSAGE_FROM_SYSTEM |
      FORMAT_MESSAGE_IGNORE_INSERTS,
      NULL,
      dw,
      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
      (LPTSTR) &lpMsgBuf,
      0, NULL );

   lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
      (lstrlen((LPCTSTR)lpMsgBuf)+lstrlen((LPCTSTR)lpszFunction)+40)*sizeof(TCHAR));
   StringCchPrintf((LPTSTR)lpDisplayBuf,
      LocalSize(lpDisplayBuf) / sizeof(TCHAR),
      TEXT("%s failed with error %d: %s"),
      lpszFunction, dw, lpMsgBuf);
   std::cout << lpDisplayBuf << std::endl;

   LocalFree(lpMsgBuf);
   LocalFree(lpDisplayBuf);
   ExitProcess(1);
}

int _tmain()
{
   // startup network
   WSADATA wsaData;
   if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0)
      ShowErrAndExit(TEXT("WSAStartup"));

   // create network socket
   SOCKET hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
   if (hSocket == INVALID_SOCKET)
      ShowErrAndExit(TEXT("Socket"));

   // connect
   sockaddr_in modem;
   modem.sin_family = AF_INET;
   modem.sin_port=htons(80);
   modem.sin_addr.s_addr = inet_addr("192.168.1.254");
   if (connect(hSocket, (sockaddr*) &modem, sizeof(sockaddr_in)) == SOCKET_ERROR)
      ShowErrAndExit(TEXT("Connect"));

   // send reboot string
   char* lpData = "GET /doc/doreboot.htm HTTP/1.1\r\nHost: 192.168.1.254\r\nConnection: keep-alive\r\nAuthorization: Basic YWRtaW46cGFzc3dvcmQ=\r\n\r\n";
   if (send(hSocket, lpData, (int) strlen(lpData) + 1, NULL) == SOCKET_ERROR)
      ShowErrAndExit(TEXT("Send"));

   // cleanup
   closesocket(hSocket);

   bool reboot = false;
   do
   {
      // wait 50 seconds
      for (int x = 0; x < 50; x++)
         Sleep (1000);

      // check for connect twice
      if (gethostbyname("www.google.com") == NULL && gethostbyname("www.yahoo.com") == NULL)
      {
         Sleep(10000);
         if (gethostbyname("www.google.com") == NULL && gethostbyname("www.yahoo.com") == NULL)
            reboot = true;
         else
            reboot = false;
      }
      else
         reboot = false;

      // connection still not established, reboot modem
      if (reboot == true)
      {
         hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

         modem.sin_family = AF_INET;
         modem.sin_port=htons(80);
         modem.sin_addr.s_addr = inet_addr("192.168.1.254");
         if (connect(hSocket, (sockaddr*) &modem, sizeof(sockaddr_in)) == SOCKET_ERROR)
            ShowErrAndExit(TEXT("Connect"));

         if (send(hSocket, lpData, (int) strlen(lpData) + 1, NULL) == SOCKET_ERROR)
            ShowErrAndExit(TEXT("Send"));

         closesocket(hSocket);
      }
   } while (reboot != false); // while reboot = true

   // cleanup
   WSACleanup();
   return 0;
}
Back to top Go down
Yaboirobby
* * * * * * * * * * *
* * * * * * * * * * *
Yaboirobby


Posts : 4322
Join date : 2009-05-21
Age : 28
Location : Atlanta, GA

C++ Reconnect Empty
PostSubject: Re: C++ Reconnect   C++ Reconnect Icon_minitimeSat 01 Aug 2009, 03:17

Sorry for the noob question, but what is this? What is C++ Reconnect?
Back to top Go down
http://mybrute-nomercy.webs.com/
Maccaz
Forum Mod
Forum Mod
Maccaz


Posts : 870
Join date : 2009-04-23
Location : Adelaide, Australia

C++ Reconnect Empty
PostSubject: Re: C++ Reconnect   C++ Reconnect Icon_minitimeSat 01 Aug 2009, 04:20

C++ is a programming language and that is what my reconnect is programmed in :)
Back to top Go down
Bruzaholman
* * * * * * * * *
* * * * * * * * *
Bruzaholman


Posts : 796
Join date : 2009-06-01
Age : 31
Location : England

C++ Reconnect Empty
PostSubject: Re: C++ Reconnect   C++ Reconnect Icon_minitimeSat 01 Aug 2009, 08:18

What modem do you have?
Back to top Go down
Maccaz
Forum Mod
Forum Mod
Maccaz


Posts : 870
Join date : 2009-04-23
Location : Adelaide, Australia

C++ Reconnect Empty
PostSubject: Re: C++ Reconnect   C++ Reconnect Icon_minitimeSat 01 Aug 2009, 08:28

Bruzaholman wrote:
What modem do you have?
Quite an old one, Billion BIPAC-7100 Pro
Back to top Go down
w13winni
VIP
VIP
w13winni


Posts : 282
Join date : 2009-04-17

C++ Reconnect Empty
PostSubject: Re: C++ Reconnect   C++ Reconnect Icon_minitimeSat 01 Aug 2009, 10:50

yes this prog send a request ( get or post) for reboot the box
i create a php script for that coupled with a .bat
just fetch the request on tamperdata for exemple
Back to top Go down
Maccaz
Forum Mod
Forum Mod
Maccaz


Posts : 870
Join date : 2009-04-23
Location : Adelaide, Australia

C++ Reconnect Empty
PostSubject: Re: C++ Reconnect   C++ Reconnect Icon_minitimeSat 01 Aug 2009, 10:59

w13winni wrote:
yes this prog send a request ( get or post) for reboot the box
i create a php script for that coupled with a .bat
just fetch the request on tamperdata for exemple

Yea it sends a GET request with the correct http headers and authorization and reboots it :)
Then checks after 50 seconds if internet is working again, and again after another 10 seconds it checks, and if not it will run the reboot again.
It does not need to POST any data,
I had to find out all the info before hand - which took only a little while.
Back to top Go down
BobTheBear
admin
admin
BobTheBear


Posts : 4102
Join date : 2009-05-15
Location : Scotland!

C++ Reconnect Empty
PostSubject: Re: C++ Reconnect   C++ Reconnect Icon_minitimeSat 01 Aug 2009, 12:50

Nice!

Your friend is clearly a handy person to know!
Back to top Go down
Maccaz
Forum Mod
Forum Mod
Maccaz


Posts : 870
Join date : 2009-04-23
Location : Adelaide, Australia

C++ Reconnect Empty
PostSubject: Re: C++ Reconnect   C++ Reconnect Icon_minitimeSat 01 Aug 2009, 12:51

BobTheBear wrote:
Nice!

Your friend is clearly a handy person to know!

I know basics of things, but he knows practically everything, he even knows ASM (assembler)
Back to top Go down
w13winni
VIP
VIP
w13winni


Posts : 282
Join date : 2009-04-17

C++ Reconnect Empty
PostSubject: Re: C++ Reconnect   C++ Reconnect Icon_minitimeSat 01 Aug 2009, 13:07

TraehDliw09 wrote:

It does not need to POST any data,
yes,you are lucky^^
but on the almost all box, we must send a postdata for reboot box
i creat .bat/php for 6 frenchs box and all need a postdata request for reboot the box
Mad but its works :)

TraehDliw09 wrote:

he even knows ASM (assembler)
ho great, this langage is very hard
Back to top Go down
Maccaz
Forum Mod
Forum Mod
Maccaz


Posts : 870
Join date : 2009-04-23
Location : Adelaide, Australia

C++ Reconnect Empty
PostSubject: Re: C++ Reconnect   C++ Reconnect Icon_minitimeSat 01 Aug 2009, 13:50

w13winni wrote:
TraehDliw09 wrote:

It does not need to POST any data,
yes,you are lucky^^
but on the almost all box, we must send a postdata for reboot box
i creat .bat/php for 6 frenchs box and all need a postdata request for reboot the box
Mad but its works :)

TraehDliw09 wrote:

he even knows ASM (assembler)
ho great, this langage is very hard

Lucky in one way, but unlucky it takes a while to reboot Sad
Back to top Go down
Sponsored content





C++ Reconnect Empty
PostSubject: Re: C++ Reconnect   C++ Reconnect Icon_minitime

Back to top Go down
 
C++ Reconnect
Back to top 
Page 1 of 1
 Similar topics
-
» reconnect.bat needed
» Can not reconnect
» reconnect.bat help!
» ALL I NEED IS A RECONNECT.BAT!!
» Creating a reconnect.bat file

Permissions in this forum:You cannot reply to topics in this forum
My Brute Forum :: Guides & Info :: Cheats & Scripts-
Jump to: