initial
This commit is contained in:
commit
af4ad93292
|
@ -0,0 +1,2 @@
|
|||
main
|
||||
.vscode/settings.json
|
|
@ -0,0 +1,286 @@
|
|||
|
||||
|
||||
#include <algorithm>
|
||||
#include <arpa/inet.h>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <condition_variable>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <netinet/tcp.h>
|
||||
#include <poll.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
|
||||
const static uint16_t PORT = 8956;
|
||||
|
||||
static bool run = true;
|
||||
|
||||
std::mutex lock;
|
||||
std::condition_variable lock_cv; // not empty or eol
|
||||
std::list<int> clients;
|
||||
|
||||
void sig_handler(int sig_num) {
|
||||
std::cerr << "signalHandler triggered" << std::endl;
|
||||
run = false;
|
||||
(void) sig_num;
|
||||
}
|
||||
|
||||
int pollSocket( int fd ) {
|
||||
struct pollfd fds;
|
||||
fds.fd = fd;
|
||||
fds.events = POLLIN;
|
||||
fds.revents = 0;
|
||||
|
||||
int res = ::poll( &fds, 1, 1000 );
|
||||
|
||||
if ( res == -1 ) {
|
||||
std::cerr << "poll failed: " << strerror( errno ) << std::endl;
|
||||
if( errno != EINTR ) {
|
||||
std::this_thread::sleep_for( std::chrono::seconds(1) );
|
||||
}
|
||||
}
|
||||
|
||||
// poisitve = event, 0 = no event, -1 = error
|
||||
return res;
|
||||
}
|
||||
|
||||
uint32_t randInRange(uint32_t lower, uint32_t upper) {
|
||||
uint32_t range = (upper-lower);
|
||||
if ( range == 0) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t rvalue = random() % range;
|
||||
return rvalue + lower;
|
||||
}
|
||||
|
||||
void sendTyped( const std::string& str, int client, uint32_t msecs = 50, uint32_t jitter = 0 ) {
|
||||
if( jitter > msecs) {
|
||||
jitter = msecs;
|
||||
}
|
||||
|
||||
for ( char c : str ) {
|
||||
::write( client, &c, 1 );
|
||||
|
||||
int32_t jitt = randInRange(0, 2*jitter) - jitter;
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds(msecs + jitt));
|
||||
}
|
||||
}
|
||||
|
||||
void sendInstant( const std::string& str, int client ) {
|
||||
::write( client, str.c_str(), str.size() );
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds(50) );
|
||||
}
|
||||
|
||||
void sendStatus( const std::string& status, int client ) {
|
||||
sendInstant( "\033[92m" + status + "\033[0m\n", client );
|
||||
}
|
||||
|
||||
std::string generateIP() {
|
||||
uint32_t addrCont = random();
|
||||
char buffer[INET_ADDRSTRLEN];
|
||||
inet_ntop( AF_INET, &addrCont, buffer, INET_ADDRSTRLEN );
|
||||
return std::string( buffer );
|
||||
}
|
||||
|
||||
std::string generatePassword() {
|
||||
std::ostringstream out;
|
||||
for( uint32_t i = 0 ; i < 16; ++i ) {
|
||||
char randChar = randInRange('!', '}');
|
||||
out << randChar;
|
||||
}
|
||||
return out.str();
|
||||
}
|
||||
|
||||
std::string scrambleIP( const std::string& ipin, uint32_t scrambleMask ) {
|
||||
std::ostringstream out;
|
||||
|
||||
for( uint32_t i = 0; i < ipin.size(); ++i ) {
|
||||
bool isDot = (ipin.at(i) == '.');
|
||||
if ( isDot ) {
|
||||
out << "\033[0m.";
|
||||
continue;
|
||||
}
|
||||
bool isScrambled = !( (1 << i) & scrambleMask );
|
||||
|
||||
if( isScrambled ) {
|
||||
char randChar = randInRange('!', '}');
|
||||
out << "\033[91m" << randChar;
|
||||
} else {
|
||||
out << "\033[92m" << ipin.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
out << "\033[0m";
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
std::string read( int client ) {
|
||||
char buffer[128];
|
||||
ssize_t rc = ::read( client, buffer, 128);
|
||||
|
||||
std::string all(buffer, rc);
|
||||
int pos = all.find('\n');
|
||||
return all.substr(0, pos < 128 ? pos : 128);
|
||||
}
|
||||
|
||||
void clientShell( int client ) {
|
||||
if( client == -1 ) return;
|
||||
|
||||
int sockVal = 1;
|
||||
::setsockopt( client, SOL_TCP, TCP_NODELAY, &sockVal, 4);
|
||||
|
||||
sendTyped("Bonjour Eliot!\n\nWhat is your target?\n", client);
|
||||
|
||||
const std::string target = read(client);
|
||||
|
||||
sendTyped("\n\nConnecting to Proxies\n", client);
|
||||
for( uint32_t i = 1; i < 8; ++i ) {
|
||||
sendTyped(std::to_string(i) + " ......... ", client, 75, 75);
|
||||
sendStatus( "Connected", client );
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds( 400 ));
|
||||
}
|
||||
|
||||
sendTyped("\nDecrypting IP-Address:\n\n", client);
|
||||
|
||||
const std::string ip = generateIP();
|
||||
uint32_t mask = 0; // 0 = invisible; 1 = decrypted
|
||||
while( ((~mask) & 0xFF'FF) ) { // limit to 16 bits / as long as one of the lower 16 bits is 0 (non visible)
|
||||
const std::string scrambled = scrambleIP( ip, mask );
|
||||
sendInstant("\r" + scrambled, client);
|
||||
|
||||
uint32_t bitToDecrypt = randInRange(0, 31);
|
||||
mask |= 1 << bitToDecrypt;
|
||||
}
|
||||
sendInstant("\r" + scrambleIP( ip, 0xFFFF ) + "\n\n", client);
|
||||
|
||||
sendStatus( "Done", client);
|
||||
|
||||
sendTyped( "Connecting to target", client);
|
||||
sendTyped( "....... ", client, 75, 50 );
|
||||
sendStatus( "Done", client );
|
||||
|
||||
sendTyped( "Generating Keylogger .....\n", client );
|
||||
sendTyped( "Uploading Keylogger .....\n", client );
|
||||
sendTyped( "Installing Keylogger ..... ", client );
|
||||
sendStatus( "Ready", client );
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::microseconds( 900 ));
|
||||
|
||||
sendTyped( "Tracking admin password ..... ", client );
|
||||
sendStatus( "In Progress", client );
|
||||
|
||||
sendTyped( "\n", client );
|
||||
|
||||
const std::string password = generatePassword();
|
||||
sendInstant( " Password: ", client );
|
||||
sendTyped( password, client, 500, 300);
|
||||
|
||||
sendInstant( "\n\n", client );
|
||||
sendStatus(" Password Saved", client);
|
||||
|
||||
sendTyped( "\nUsing Password to crack Firewalls.....", client );
|
||||
sendStatus( "Cracked", client);
|
||||
|
||||
sendTyped( "\n \033[92mAccess Granted\n\n You are in!\033[0m\n\n", client);
|
||||
|
||||
sendTyped( target + "> ", client);
|
||||
|
||||
::close( client );
|
||||
}
|
||||
|
||||
void backgroundTask() {
|
||||
while ( run ) {
|
||||
int nextClient = -1;
|
||||
{
|
||||
std::unique_lock<std::mutex> guard(lock);
|
||||
if( clients.empty() ) {
|
||||
lock_cv.wait(guard);
|
||||
}
|
||||
if ( clients.empty() ) {
|
||||
// no more clients
|
||||
break;
|
||||
}
|
||||
nextClient = clients.front();
|
||||
clients.pop_front();
|
||||
}
|
||||
|
||||
clientShell( nextClient );
|
||||
}
|
||||
}
|
||||
|
||||
int main () {
|
||||
// init rand seed
|
||||
srand(time(NULL));
|
||||
|
||||
int sock = ::socket( AF_INET6, SOCK_STREAM, 0 );
|
||||
if ( sock == -1 ) {
|
||||
std::cerr << "can not create socket: " << strerror(errno) << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct sockaddr_in6 myAddr;
|
||||
std::memset( &myAddr, 0, sizeof(myAddr));
|
||||
myAddr.sin6_family = AF_INET6;
|
||||
myAddr.sin6_addr = IN6ADDR_ANY_INIT;
|
||||
myAddr.sin6_port = htons( PORT );
|
||||
int res = ::bind( sock, (struct sockaddr*) &myAddr, sizeof( myAddr) );
|
||||
if ( res == -1 ) {
|
||||
std::cerr << "bind failed " << strerror( errno ) << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
res = ::listen( sock, 4 );
|
||||
if ( res == -1 ) {
|
||||
std::cerr << "failed to listen " << strerror( errno ) << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::thread backgroundThread( backgroundTask );
|
||||
|
||||
::signal(SIGINT, sig_handler);
|
||||
::signal(SIGTERM, sig_handler);
|
||||
|
||||
while ( run ) {
|
||||
int status = pollSocket( sock );
|
||||
if ( status > 0 ) {
|
||||
struct sockaddr_in6 addr;
|
||||
socklen_t socklen = sizeof( addr );
|
||||
int client = accept( sock, (struct sockaddr*) &addr, &socklen );
|
||||
if ( client > -1 ) {
|
||||
char buffer[INET6_ADDRSTRLEN];
|
||||
inet_ntop(addr.sin6_family, &addr.sin6_addr, buffer, INET6_ADDRSTRLEN);
|
||||
std::cout << "accepted Client: " << buffer << std::endl;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(lock);
|
||||
clients.push_back( client );
|
||||
}
|
||||
lock_cv.notify_one();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// notify thread
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(lock);
|
||||
clients.clear();
|
||||
}
|
||||
lock_cv.notify_all();
|
||||
|
||||
if( backgroundThread.joinable() ) {
|
||||
backgroundThread.join();
|
||||
}
|
||||
|
||||
::close(sock);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue