Skip to main content

Posts

Showing posts from May, 2018

VB script to change ssh password

'this code will read IPs from host.txt file and change the passwords Option Explicit Dim objFile, strLine Dim sInput,nInput,rInput,WshShell Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject") sInput = InputBox("Enter your old password") nInput = InputBox("Enter your new password") rInput =InputBox("Enter your reenter new password") set WshShell = WScript.CreateObject("WScript.Shell") Set objFile= objFSO.OpenTextFile("hostname.txt", 1) Do While Not objFile.AtEndOfStream strLine = objFile.readline WshShell.Run "putty.exe "&strLine&":22 -l demo -pw "&sINPUT WScript.Sleep 2000 WshShell.AppActivate strLine&":22 - PuTTY" WshShell.SendKeys "passwd {ENTER}" WScript.Sleep 1000 WshShell.SendKeys sINPUT&"{ENTER}" WScript.Sleep 1000 WshShell.SendKeys nINPUT&"{ENTER}" WScript.Sleep 1000 WshShell.SendKeys r...

Disabling DEP(data Excecution prevention) for third party softwares in windows

1.go to system properties. 2.go to Advanced system settings . 3. go to Advance tab ,performance settings,Data execution prevention tab make sure u have selected 1st option as highlighted in screenshot.after making changes you must restart system

Disabling and enabling TLS

1.Press win+R 2.Type regedit 3.go to  Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS (version)\Client  Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS (version)\Server set the Dword value to 1 for enabling TLS client and 0 to disable enable TLS will make systems vulnerable 

disabling SSL in windows

1.Press win+R 2.Type regedit 3.go to  Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Client set the Dword value to 1 for enabling SSL client and 0 to disable

Java function to read from sql database

 public static ResultSet sqlread(String S){       ResultSet rs = null;        try     {       // create a mysql database connection       String myUrl = "jdbc:mysql://localhost:3306/firewall?zeroDateTimeBehavior=convertToNull";       Class.forName("com.mysql.jdbc.Driver");       Connection conn = DriverManager.getConnection(myUrl, "root", "Cns@54321");             Statement st = conn.createStatement();       // note that i'm leaving "date_created" out of this insert statement         rs = st.executeQuery(S);           }        catch (Exception e)     {       System.err.println("Got an exception!");       System.err.println(e.getMessage());     }        return rs;   } 

java function to write into sql database from java

public static void runsql(String Q)   {     try     {       // create a mysql database connection           String myUrl = "jdbc:mysql://localhost:3306/firewall?zeroDateTimeBehavior=convertToNull";       Class.forName("com.mysql.jdbc.Driver");       Connection conn = DriverManager.getConnection(myUrl,"root", "password");       if (conn != null) {     System.out.println("Connected"); }       Statement st = conn.createStatement();             st.executeUpdate(Q);       conn.close();     }     catch (Exception e)     {       System.err.println("Got an exception!");       System.err.println(e.getMessage());     }   }

Java functions to run SSH commands from java

     public static void SSH(String Host,String username,String passwor,String cmd,String cmd1) {   byte[] tmp = new byte[1024]; String host =Host; String user =username; String password =passwor; String  command = cmd;                 String ou=null; try { Properties config = new Properties(); config.put("StrictHostKeyChecking", "no"); JSch jsch = new JSch(); // Create a JSch session to connect to the server Session session = jsch.getSession(user, host, 22); session.setPassword(password); session.setConfig(config); // Establish the connection session.connect(); System.out.println("Connected..."); ChannelExec channel = (ChannelExec) session.openChannel("exec"); channel.setCommand(command); channel.setErrStream(System.err);                         channel.connect();       ...

Function create and write in to a file

 public static void fc(String S){         try {             File file = new File("C:\\Users\\hell\\Documents\\fg.txt");             //Create the file if (file.createNewFile()){     System.out.println("File is created!"); }else{     System.out.println("File already exists."); } //Write Content FileWriter writer = new FileWriter(file); writer.write(S); writer.close();         } catch (IOException ex) {             Logger.getLogger(JMS.class.getName()).log(Level.SEVERE, null, ex);         }   }

Encryption and Decryption functions for Java

    public static String encrypt(String key, String initVector, String value) {         try {             IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));             SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");             Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");             cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);             byte[] encrypted = cipher.doFinal(value.getBytes());             System.out.println("encrypted string: "                     + Base64.encodeBase64String(encrypted));             return Base64.encodeBase64String(encrypted);         } catch (Exception ex) {   ...

restart services remotely using power-shell script( restart.ps1)

FUNCTION Restart-Service { PARAM([STRING]$SERVERNAME=$env:COMPUTERNAME,[STRING]$SERVICENAME) #MSSQLSERVER FOR DEFAULT INSTANCE FOR NAMED INSTANCE MSSQL`$KAT $SERVICE = GET-SERVICE -COMPUTERNAME $SERVERNAME -NAME $SERVICENAME -ERRORACTION SILENTLYCONTINUE IF( $SERVICE.STATUS -EQ "RUNNING" ) { $DEPSERVICES = GET-SERVICE -COMPUTERNAME $SERVERNAME -Name $SERVICE.SERVICENAME -DEPENDENTSERVICES | WHERE-OBJECT {$_.STATUS -EQ "RUNNING"} IF( $DEPSERVICES -NE $NULL ) { FOREACH($DEPSERVICE IN $DEPSERVICES) { Stop-Service -InputObject (Get-Service -ComputerName $SERVERNAME -Name $DEPSERVICES.ServiceName) } }   Stop-Service -InputObject (Get-Service -ComputerName $SERVERNAME -Name $SERVICE.SERVICENAME) -Force    if($?)    {    Start-Service -InputObject (Get-Service -ComputerName $SERVERNAME -Name $SERVICE.SERVICENAME) $DEPSERVICES = GET-SERVICE -COMPUTERNAME $SERVERNAME -NAME $SERVICE.SERVICENAME -DEPENDENTSERVICES | WHERE-OBJECT ...

SMB disabling

Start the registry editor (regedit.exe). Move to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters. From the Edit menu, select New, DWORD value. Enter a name of Smb2 and press Enter. Double-click the new value and set to 0 to disable SMB 2. Set to 1 to enable. Reboot the machine.