Skip to main content

SSHD on Windows 7 (somewhat covert)


I recently had an Admin password and wanted a persistent backdoor on a x64 Windows7 box I had physical access to for a limited amount of time.

I thought about putting a bind shell on the box, but then not only would I have to open a port up through the firewall, but also if I killed the session my bind shell would exit, and I'd lose my ability to connect back in.  So I ditched the bind shell idea. 

A reverse shell seemed like the way to go.  This had the benifit of if I moved off the LAN, I could get back in through the NAT firewall.

The question was, how do I make a persistent reverse shell?  Even though I was Admin, when my trojan connected back to my attack platform, it only had User privs, so I couldn't 'run scheduleme' in Meterpreter to set up a service (darn Windows7!). I tried using the Windows Scheduler, creating a task to run my trojan to connect back to me every 10 minutes.  This worked OK at first.  I was worried that if I scheduled it to connect back to me every 10 minutes, that the victim would get a new session process every 10 minutes, and I'd fill up the box... but in testing, if I wasn't listening when the session tried to connect back to me, it would simply exit cleanly. So I thought I was done.  But then, I noticed that even though I had the task in the scheduler, and even though it would work for a while, it would always quit connecting back to me (even though the task was still scheduled).  I played with the scheduler, and no matter how I scheduled the task, it seemed that it would quit calling back to me.  The reason is unknown, but the symptoms persisted... I couldn't get the scheduler to keep calling back to me, even though it SAID it was scheduled.  I added this to my list to research later on, but needed a quick solution.

As a quick work-around, and since I had physical access and the victim was on the LAN with my attack box, ssh seemed like a good solution.  Ssh is robust, and I could use it to run my payload anytime I wanted the victim to connect back to me.  I tried to install OpenSSH.  However, Openssh doesn't work well (at all?) with Windows 7.  So instead I used CopSSH (ver 4.1).  When you install it, a control pannel comes up to configure it.  To get CopSSH to run as a service (every time the PC boots up), you have to create a new user.  That is a major downside, as this user will show up in the logon menu.

Don't forget to run the CopSSH Control Panel as Admin, or your service won't run every time you boot the box!

After I made the new user, ran the CopSSH Control Panel as Admin, and told it to start with this User, I then hid the user from the logon screen with the below.

[Hide User Accounts in windows Vista and Windows 7 (from technet forums):
at Run type regedit
Once in regedit go to HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\Winlogon
In the left panel, right click on Winlogon and click New and click Key.
Type SpecialAccounts and press Enter
In the left panel, right click on SpecialAccounts and click New and click Key.
Type UserList and press Enter.
In right panel of UserList, right click on a empty area and click New then click DWORD (32bit) Value.
Type in the name of the user account that you want to hide and press Enter.eg: Everyday Account.
In the right panel, right click on the user account name and click Modify.

To hide the user account ? Type 0 and click OK. (number zero not the letter)
Whenever you want to use the account just unhide the it by typing 1 instead of zero.]

Now I have a box that I can SSH into, and then click on my payload to create a session back to my box.

If anyone knows how to fix the scheduler so that it actually reliably runs my task, or if you know how to get my trojan to run with Admin privs (and right-click 'run as Admin' didn't work) please let me know!

Comments

Popular posts from this blog

HP c6180 Printer and Vista

Hp c6180 driver issues with Vista Home Premium My wife has a Vista Home Premium laptop, and the HP C6180 Photosmart printer keeps disappearing from her available printers.  The only way I've found to fix the problem is to reinstall all the HP software. When I do this, I have to download the (large..507M software from HP, or reinstall the printer (ONLY the printer, not the scanner) with the installation disk, as the drivers are not discovered with a "Windows Update" setting.  My guess is that is because HP doesn't like people to install only the printer driver, which would be easy, but they want folks to install all their crapware as well, so they are withholding the drivers from the on-line Microsoft printer database.  So keep your installation CD!  I've also found that unless I install everything on the CD or in the Full Version download (HP Customer Participation Program, HP Imaging Device functions, HP OCR SW, HP All-In-one SW, HP Photosm...

atftpd vs tftpd-hpa

Recently I was trying to tftp files from a Windows computer to a Kali box.   One version of Windows worked, but another didn't.    After much troubleshooting, here were my symptoms: I could tftp a file from-to any Kali box from-to another Kali box I could NOT tftp files to a specific Windows 7 box from any Kali box I could NOT tftp files to a Chrooted-Ubuntu-Chromebook box from a Kali box After MUCH troubleshooting, going through every setting in atftpd, it seemed like it literally was a client OS problem.  Different clients simply would not download files---unacceptable. Thus, I switched to tftpd-hpa.   To install: apt-get install tftpd-hpa files go to/come from /srv/tftp, but it needs to be a tftp user. Thus, I needed to: chroot -R /srv/tftp Also, if you want to be able to put files ON the tftp server (from a client), you need to modify /etc/default/tftpd-hpa: change "TFTP_OPTIONS="--secure"  to "TFTP_OPTIONS="--secure --create" ...

Temper Temperature monitor on a Beaglebone Black

Beaglebone Black as a temperature monitor: Recently I wanted to monitor the temperature of my shed.  I thought I'd use a small computer such as a Raspberry Pi or a Beaglebone or Odroid. My Raspberry Pi boxes were all in use, so I grabbed my Beaglebone, which was doing nothing. I flashed it with the  Debian   9.3   2018-03-05   4GB SD   IoT   image, but that seemed like it was running lots of bloatware and the ethernet interface wouldn't take a static IP with /etc/network/interfaces. So I went with the  Debian   9.3   2018-01-28   4GB SD   LXQT   i  image instead.  I still had the same problem, that lots of junk was running, and I couldn't configure my interface by modifying /etc/network/interfaces So my first step was to get rid of all the bloatware.  If you're using a Raspberry Pi or something, you can skip this and just go to the second step below STEP 1--Remove Blotatware from Beaglebone Black...