-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhoney.cpp
110 lines (88 loc) · 2.56 KB
/
honey.cpp
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstring>
#include <fstream>
using namespace std;
int main()
{
int port;
string buffer;
string rootornot;
string myText;
ifstream MyReadFile("rootornot.txt");
ofstream MyFile("ftpmsg.txt");
string input;
char yorn;
system("figlet HoneyPot");
cout << endl;
cout << "\t\t\t\t~ Madhav Shah" << endl;
cout << endl;
cout << endl;
cout << "On what port do you want to start honeypot? " << endl;
cin >> port;
if (port > 65535 || port < 0)
{
cout << "Invalid Port";
}
else
{
if (port < 1023 && port > 0)
{
system("whoami > rootornot.txt");
while (getline(MyReadFile, myText))
{
// cout << myText;
rootornot = myText;
}
cout << rootornot;
if (rootornot == "root")
{
goto rooted;
}
else
{
cout << "RUN ME AS A ROOT FOR LISTNING ON KNOWN PORTS !" << endl;
}
}
else
{
rooted:
string stringport = to_string(port);
switch (port)
{
case 22:
buffer = "nc -nlvp " + stringport;
cout << buffer << endl;
system(buffer.c_str());
break;
case 21:
cout << "Do you want to show any message? (y - Yes n -No)" << endl;
cin >>yorn;
if (yorn=='y')
{
cout<<"Enter Message"<<endl;
cin >> input;
fstream file("ftpmsg.txt");
MyFile << input << endl;
MyFile.close();
system("while true; do nc -nvlp 21 -q 2 < ftpmsg.txt;echo 'Ilustrator detected!'; done");
}
else if(yorn=='n'){
system("while true; do nc -nvlp 21 -q 2;echo 'Ilustrator detected!'; done");
}
else{
cout<<"Wrong Input"<<endl;
}
break;
default:
buffer = "nc -nlvp " + stringport;
cout << buffer << endl;
system(buffer.c_str());
break;
}
}
return 0;
}
}