-
Notifications
You must be signed in to change notification settings - Fork 0
/
NRScriptLeonard.sh
138 lines (110 loc) · 3.91 KB
/
NRScriptLeonard.sh
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
#1.Install relevant applications on the local computer.
#Get initial IP address and country. Setup the variables necessary for later.
#This function pulls the ip and country info at start state."
function Originchk()
{
BaseIP=$(curl -s ipinfo.io/ip)
BaseCountry=$(curl -s ipinfo.io/country)
echo "Your base IP is $BaseIP, located in $BaseCountry."
}
Originchk
#This fucntion gets the base system initialised with an apt update and installing required dependencies."
function initialise()
{
#Add in apps as needed, assume nmap, ssh, whois are all not installed.
sudo apt update && sudo apt install -y sshpass nmap ssh whois openssh-client tor
}
#This function gets Nipe installed and setup including 'running it' once to circumvent its janky errors.
function nipemeup()
{
cd ~
echo "Setting current location to:"
pwd
# Download the repository
git clone https://github.com/htrgouvea/nipe && cd nipe
# Install libs and dependencies
echo "Yes" | sudo cpan install Try::Tiny Config::Simple JSON
#Nipe installation must be run as root.
sudo perl nipe.pl install
#Nipe is janky and silly. Its seems nipe needs to be started and stopped first before it can work.
cd ~/nipe
sudo perl nipe.pl start
sudo perl nipe.pl stop
sudo perl nipe.pl status
}
#Text output to explain what is happening and to call on the functions above. Empty echo's to space the text.
echo
echo
echo "Getting your system ready.................."
echo
echo -e "Initialising.\n Please provide root password when prompted."
echo
initialise
echo
echo "Proceeding to get Nipe setup."
echo
nipemeup
###########################################################################
#2. Check if the connection is anonymous
#~ Check if the connection is from your origin country. If no, continue.
#~ Available tools: curl, whois
#Get current IP address and country. Setup the variables.
function Currentchk()
{
CurrentIP=$(curl -s ipinfo.io/ip)
CurrentCountry=$(curl -s ipinfo.io/country)
echo "Your current IP is $CurrentIP, located in $CurrentCountry."
}
#Function to start Nipe and check the current status
function anoncheck()
{
cd ~/nipe
echo "Moving you to the correct directory:";
pwd
statuschk=$(sudo perl nipe.pl status | grep -w activated)
if [ ! -z "$statuschk" ]
then
echo "Nipe is active."
echo
else
echo "Nipe is not yet active, you are exposed. Starting Nipe now."
echo
fi
}
Currentchk
echo "Checking things are in order. Nipe is working and your location is obfuscated."
echo
echo
#If statement to compare countries from start state with current state and ensure location is obfuscated.
if [ "$CurrentCountry" != "$BaseCountry" ];
then
echo "You are anonymous."
else
echo -e "You are exposed, but I will take care of it. \n Just a moment......."
echo
echo
anoncheck
cd ~/nipe
sudo perl nipe.pl start
anoncheck
sudo perl nipe.pl status
fi
#~ 3. Connect automatically to the VPS and execute tasks
#~ Once the connection is anonymous, communicate via SSH and execute nmap
#~ scans and whois queries.
#~ Available tools: sshpass, ssh
#Digital Ocean Ubuntu Test Environment 128.199.179.192. Not worrying about the VPS security here.
#User root
#Password LkNRTest!B0X
echo "You are all set. Connecting you to 128.199.179.192"
sshpass -p 'LkNRTest!B0X' ssh -o StrictHostKeyChecking=no root@128.199.179.192 'apt update && apt install -y nmap ssh sshpass whois && nmap -oA scanresults -Pn $(curl -s ipinfo.io/ip) && whois $(cat scanresults.gnmap | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | uniq) >> whoisresults'
#Get the outputs thank you very much.
echo "Getting you your files, please check ~/ for scanresults.gnmap and whoisresults files."
sshpass -p 'LkNRTest!B0X' scp root@128.199.179.192:"scanresults.gnmap" ~/ && sshpass -p 'LkNRTest!B0X' scp root@128.199.179.192:"whoisresults" ~/
#Change directory and show where files have been saved.
cd ~/
filestore=$(pwd)
echo -e "Your files are located here in $filestore. \n Listing them here for you now."
echo
ls