-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbeacon.cpp
More file actions
46 lines (35 loc) · 1.75 KB
/
beacon.cpp
File metadata and controls
46 lines (35 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Simple Beacon Simulator
// Input: URL and frequency to beacon (in seconds)
// Output: Beaconing web requests to a URL at a user-defined interval
// Requirements - curl or wget
// For questions ask Tony.Lee-at-Foundstone.com
#include <stdio.h>
#include <unistd.h>
#include <string>
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[])
{
printf("This program will beacon out to a website on a user-defined schedule to simulate malware. (Use ctrl+c to stop the beaconing)\n");
printf("Email Tony.Lee-at-Foundstone.com for questions.\n\n");
if ( argc != 3 ) // Detect command line arguments - 2 are needed for correct execution
{
printf( "Usage: %s <URL> <Frequency in seconds>\n", argv[0] );
printf( "Example: %s http://www.dot.tk/en/index.html?lang=en 60\n", argv[0] );
return 1;
}
unsigned int seconds = strtoul(argv[2],NULL,0); // sleep takes an unsigned int, must convert string input to unsigned long
std::string command; // initialize command
command = "wget -O /dev/null "; // build the first part of the string
command += argv[1]; // add the URL
const char * charcommand = command.c_str(); // convert string to char*
while(1)
{
printf("\nGetting the site %s\n", argv[1]); // user notification output
system( charcommand ); // execute wget
printf("\n\nSleeping for %u seconds\n\n", seconds); // user notification output
sleep(seconds); // sleep
}
return 0;
}