All the Best !!!
Saturday, April 15, 2017
Friday, April 14, 2017
Thursday, December 29, 2016
Java Telnet example : testing remote service state
In most of the cases in daily job, you must have get into some situation where you needed to telnet to a machine. Although telnet is not a secure way to access remote machine, but still it can be useful if all we want to know if the particular service port on particular machine is running or not(for example you want to check say on local ip address 192.168.110 on port 3389 the RDP service is running or not and there may be other cases)
Below, we will be showing up sample code in java which you can use the automate the process. This can also be used anywhere like if you are writing a service to report health of the multiple services, just a case.
import org.apache.commons.net.telnet.TelnetClient; import java.io.IOException; import java.net.ConnectException; public class JavaTelnetExample { private static final String RDP_SERVER = "10.66.6.62.1"; private static final int RDP_SERVER_PORT = 3389; private static final String HTTP_SERVER = "10.66.62.2"; private static final int HTTP_SERVER_PORT = 80; // Similar to above you can test state for number of other services on number of other machines public static void main(String[] args) { System.out.println("Rdp service status on server ip : " + RDP_SERVER + " , port : " + RDP_SERVER_PORT + " = " + isServiceRunning(RDP_SERVER, RDP_SERVER_PORT)); System.out.println("Ssh service status on server ip : " + HTTP_SERVER + " , port : " + HTTP_SERVER_PORT + " = " + isServiceRunning(HTTP_SERVER, HTTP_SERVER_PORT)); } // If able to connect successfully, return true for service state else return false. private static boolean isServiceRunning(String ip, int port) { try { TelnetClient telnetClient = new TelnetClient(); telnetClient.connect(ip, port); return true; } catch (ConnectException e) { return false; } catch (IOException e) { return false; } } }
Note:
To run this code, you can download the dependencies 'Apache Commons Net' from the https://mvnrepository.com/artifact/commons-net/commons-net depending upon build tool you are using maven/gradle or jar file
Feel free to leave comment if you get any issue or any suggestion.
Sunday, June 19, 2016
2 Steps to restrict Jenkins access by IP address or Host Name
Steps to fresh jenkins installtion on on Apache Tomcat Server : http://www.automatethebox.com/2016/06/installing-jenkins-on-apache-tomcat.html
If Jenkins is installed on Tomcat Server
- Add any of the below entry in the conf\context.xml file :
- <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127.0.0.1"/><!--Allow from Ip Address-->
- <Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="127.0.0.1"/><!--Deny from Ip Address-->
- <Valve className="org.apache.catalina.valves.RemoteHostValve" allow="yahoo.com"/><!--Allow from a Domain-->
- <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|202.43.25.244"/><!--Allow from multipl ip's-->
- Restart the Tomcat Server
Now, when you try to access Jenkins url, you should get 403 error
If Jenkins is installed on Apache Server
- Add all of the below entries in the conf\.htaccess file to allow access from ip '45.67.87.67' and '10.66.62.0/24' LAN only
- Order Deny,Allow
- Deny from all
- Allow from 45.67.87.67
- Allow from 10.66.62.0/24
- Restart the Apache Server
Now, when you try to access Jenkins url, you should get 403 error
Installing Jenkins on Apache Tomcat Server
First of all if you have not installed the Apache Tomcat Server, We will be going to install it on Windows following the below steps :
- Download the Apache Server from Url : http://www.apache.org/dyn/closer.cgi
- Extract the Tomcat zip folder
- Navigate to to 'conf' directory, path may be somewhat like '..\apache-tomcat-9.0.0.M8\conf' from where you have extracted the zip.
- Open the Server.xml file and edit the PORT where you want the Tomcat to listen for the requests
- Now start Command Prompt and go to '..\apache-tomcat-9.0.0.M8\bin' and call 'startup.bat'
- Now start a browser and navigate to url '<your_system_ip:port_specified_in_step4>'. Example : 127.0.0.1:8080
- You should see Tomcat Successfully installed page. Congratulation!
Now, we will be moving to next part of configuring Jenkins behind the Tomcat Server :
- Download Jenkins.war file from https://jenkins.io/
- Once downloaded, unzip and move the jenkins.war to directory '.\apache-tomcat-9.0.0.M8\webapps'
- Restart the Tomcat. CTRL+C or call the .\apache-tomcat-9.0.0.M8\bin\shutdown.bat' and then start again.
- Now when you navigate to 127.0.0.1/jenkins, you should see jenkins successfully installed.
Feel free to leave comments !!!
Sunday, March 20, 2016
Connecting to MySql from java with Maven
In this example we will be creating a simple maven java project to connect to the local mysql instance, without actually installing any jdbc connector and setting it to classpath (maven will take care of this :))
1. Add MySQL connector maven dependency in the pom.xml
2. Sample java source file: Connecting to local mysql instance and listing tables;
1. Add MySQL connector maven dependency in the pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.automatethebox</groupId>
<artifactId>mysql-connect-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
</dependencies>
</project>
2. Sample java source file: Connecting to local mysql instance and listing tables;
package com.automatethebox.mysql_connect_maven;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class MySqlConnectionWithMaven {
public static void main(String[] args) {
// Databases url (here 'information_schema' is database name)
String databaseUrl = "jdbc:mysql://localhost/information_schema";
String jdbcConnectorClass = "com.mysql.jdbc.Driver";
String mysqlUser = "root";
String myUserPass = "Admin@123";
String query = "Select distinct(table_name) from INFORMATION_SCHEMA.TABLES";
try {
Class.forName(jdbcConnectorClass);
Connection connection = DriverManager.getConnection(databaseUrl, mysqlUser, myUserPass);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String tableName = resultSet.getString(1);
System.out.println("Table : " + tableName);
}
connection.close();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
Friday, March 4, 2016
Disable Java JVM Default DNS Caching
You can disable the Java Virtual machine default DNS caching following any of the below methods
( By Default java 1.6 caches all the DNS queries ):
- Method 1(Changes while staring up JVM)
- Add -Dsun.net.inetaddr.ttl=0 while starting up the JVM.
- Method 2(Changes in java config file)
- Add/Edit the property networkaddress.cache.ttl=0 in %JRE%/lib/security/java.security file. Here JRE refers to Java Runtime Environment folder.
- Method 3(Changes in your code)
- Set the property in you java code as java.security.Security.setProperty("networkaddress.cache.ttl", "0" );
Sunday, December 20, 2015
Solving Gradle DSL method not found : 'android()'
Getting "Gradle DSL method not found : 'android()" error, well then you are at right place to solve the things :)
Solution:
- Open the project top level 'build.gradle' file
- Remove the below configuration android() method
// Delete these lines from project top level 'build.gradle' file
android {
compileSdkVersion 23
buildToolsVersion '22.0.1'
}
- Save the changes and re-compile
Configure Jenkins email notifications
In this tutorial we will discuss about setting up the email notification in your Jenkins environment from the start :
Part I: Configure the email notifications from Jenkins Management section.
Part II : Configure the email notification for the individual Jenkins job
Part I: Configure the email notifications from Jenkins Management section.
Part II : Configure the email notification for the individual Jenkins job
Part I: Configure the email notifications from Jenkins Management section.
Part II : Configure the email notification for the individual Jenkins job
Part I: Configure the email notifications from Jenkins Management section.
- First you should be logged in to Jenkins interface as Administrators, so you should see 'Manage Jenkins' link on the left side options.
- Click on the 'Manage Jenkins', to navigate to 'Manage Jenkins' page. 'Configure System' option should be available
- Click on the 'Configure System' link, scroll down on 'Configure System' page, you should see the 'Email notifications' section.
- Set the following settings in the 'Email notification' section [We are taking yahoo domain for example]
- SMTP Server : smtp.mail.yahoo.com
- Check 'Use SMTP Authentication'
- Username : <email address to send emails> Example : test@yahoo.com
- Password : <used email address password>
- Check 'Use SSL'
- SMTP Port : 465
- Reply-To-Address : <email address to reply emails, can be same email or different>
- Charset : UTF-8
- Scroll up on the page and now set following settings in 'Locations' section
- System admin e-mail address : <email address to send emails> Example : test@yahoo.com
- Now to test your email configurations, Scroll down to 'Email Notification' section.
- Check 'Test Configuration by sending test e-mail'
- Test e-mail recipient : <recipient email address to test configuration> Example: youremail@yahoo.com
- Click on "Test Configuration" button.
- You should see message 'Email was successfully sent'. It yes, congrats you have successfully configured Jenkins email notifications :)
- 'Apply' and 'Save' the changes.
- Navigate to configuration page of Jenkins job, for which you wants to send a email notification. For example we have a job 'test-email-notification'
- Under 'Post Build Actions', click on 'Add post build action' and select 'Email Notification' option.
- Now, when the 'Email notification' section visible. Provide the recipients email addresses and select other check box options per your requirement
- Click on Apply and Save the changes.
Feel free to leave your comments in case of any issues in above steps... :)
Saturday, December 12, 2015
Some helpful commands to build multi-module maven project tests
Build and execute tests from all the sub modules
- mvn clean install
Build and execute tests from a specific sub module
- mvn clean install -pl <module-name> -am
Build and execute a specific test from a specific sub module
- mvn -DfailIfNoTests=false -Dtest=<test-class-name> clean install -pl <module-name> -am
- mvn -DfailIfNoTests=false -Dtest=<test-class-name#test-method-name> clean install -pl <module-name> -am
Saturday, April 4, 2015
An error occurred while resigning the app 'selendroid-test-app-0.15.0.apk'
An error occurred while resigning the app 'selendroid-test-app-0.15.0.apk'
If you got the same error message while trying to start the Selendoid server with your apk file, try the below to fix it :
Solution :
- Check JAVA_HOME is set properly
- Set System variable with name "JAVA_HOME" with value set to Java jdk like "C:\Program Files\Java\jdk1.8.0_40\"
- Check ANDROID_HOME is set properly
- Set System variable with name "ANDROID_HOME" with value set to Android Sdk like "C:\Users\lalit\AppData\Local\Android\sdk\"
Still after setting the above variables correctly, if you see any error try to sign your app manually using below command
C:\Program Files\Java\jdk1.8.0_40\bin> jarsigner.exe -sigalg MD5withRSA -digestalg SHA1 -signedjar < apk file path > -storepass android -keystore <keystore location> < apk file path > androiddebugkey
Example:
C:\Program Files\Java\jdk1.8.0_40\bin > jarsigner.exe -sigalg MD5withRSA -digestalg SHA1 -signedjar C:\Users\lalit\Downloads\selendroid-test-app-0.15.0.apk -storepass android -keystore C:\Users\lalit\.android\debug.keystore C:\Users\lalit\Downloads\selendroid-test-app-0.15.0.apk androiddebugkey
If it fails and throws error like jarsigner: unable to open jar file
Solution :
- Try to rename your *.apk file to *.zip
- Open the zip file and verify its opened successfully, and if it does not then its currupt apk file :( and need to be changed :)
Friday, March 20, 2015
Automatic logon in windows XP/7/8/Windows Server
- Open the Windows Registery editor from run.exe [ type regedit and ENTER ]
- Navigate to "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\winlogon"
- Set or create the following keys (DWORD, String, String)
- AutoAdminLogon = "1"
- DefaultUserName = Your user name
- DefaultPassword = Your password
- Restart and now machine will be automatically logged in :)
Thursday, January 22, 2015
The host supports Intel VT-x, but Intel VT-x is disabled
"The host supports Intel VT-x, but Intel VT-x is disabled" is thrown - on trying to start a virtual machine e.g using VMware Player; when the Virtual Technology(VT) is disabled from system BIOS Settings.
| The host supports Intel VT-x, but Intel VT-x is disabled |
Steps to fix this and run virtual machines successfully :-
- Close all the application and restart the System.
- Press F10 on system startup, to go to Bios Settings
- Enable the Virtual Settings from Bios Settings > System Configuration
- Save the Changes and Start the System.
Video link :
Now try to start your virtual machine :) it should start without any error now :)
Monday, January 19, 2015
Install and run Sqlmap on Windows
Sqlmap is the most popular tool for finding and exploiting the sql vulnerability on the web. It is written in python for cross platform, today i will show the simple steps to install it on the Windows environment ( i am doing it on windows 8.1 :D )
- Download and install the Python interpreter from https://www.python.org/downloads/ on your System. Python 2.7.9 version should be fine.
- Now download the Sqlmap zip file from http://sqlmap.org/
Sqlmap is installed successfully and ready to roll and hack someone database :D ;)
Sunday, January 11, 2015
Android Json tutorial : Saving custom class object as JSONObject and JSONArray on Parse
Android JSONObject and JSONArray allows you to save your custom class values on the Parse.com as a json string.
Suppose you would like to save your custom class values in a single Parse.com class column, you can just convert your class parameter values in JSONObject and then can save in a column on Parse.com.
Saving JSONObject on Parse
Saving JSONArray on Parse [ If you like to save an array of custom class instances]
Suppose you would like to save your custom class values in a single Parse.com class column, you can just convert your class parameter values in JSONObject and then can save in a column on Parse.com.
Saving JSONObject on Parse
// Create a Parse object for the table under which you like to add your json object in a column.
ParseObject parseObject = new ParseObject("MainTable");
// Add your JSONObject
parseObject.put("myCustomClass",new JSONObject().put("key","value"));
// Tip : Here you can add all of your custom class variable as key value pair in JSONObject
// Save the Parse object
parseObject.saveInBackground();
Saving JSONArray on Parse [ If you like to save an array of custom class instances]
// Create a Parse object for the table under which you like to add your json object in a column.
ParseObject parseObject = new ParseObject("MainTable");
// Add your JSONArray
JSONArray jsonArray = new JSONArray("myCustomClassArray");
jsonArray.put(new JSONObject().put("key1","value1"));
jsonArray.put(new JSONObject().put("key2","value2"));
// Tip : Here you can add all of your custom class variable as key value pair in JSONObject
// Save the Parse object
parseObject.saveInBackground();
Monday, January 5, 2015
The working copy at XXX is too old (format XXX) to work with client version XXX (rXXX)’ (expects format XX). You need to upgrade the working copy first.
The working copy at XXX is too old (format XXX) to work with client version XXX (rXXX)’ (expects format XX). You need to upgrade the working copy first.
You are at right place for the solution, if you faced the error message like above while using svn client.
Reasons why this error occurs:
You are at right place for the solution, if you faced the error message like above while using svn client.
Reasons why this error occurs:
- You have installed a newer version of svn client on your machine, and trying to add/commit some new files to svn server from you current working copy.
Easy fix 1:
- Go to your svn checked project > right click > select 'upgrade the Working copy'
- This will upgrade the working copy and now you should be able to add/commit file easily.
Easy Fix 2:
- Still after applying the fix above, issue is not fixed :(. You can try below then:
- Right click on the folder causing the issue.
- If on right click it does not have any svn 'upgrade the working copy'
- Then go under the folder delete the ".svn" folder completely
- Add/commit the remaining files to svn :) it will no give any error :)
Thank you for reading :)
Sunday, January 4, 2015
Mcafee - Internet Security antivirus extend trial period free trick
Like one of my previous blog post on extending a software trial period, here comes the same trick to get the McAfee - Internet Security antivirus free extended subscription just by changing system date and time.
Simple 2 step to extend the trial period and get free subscription :)
| McAfee trial period expired |
- As you can see expired trial period screenshot on dated 04-01-2014. Change the System date to previous date say '01-01-2014' in our case.
Change system date to previous months or years - Close the McAfee and start again. and Bingooooo !!!! free subscription activated
McAfee free subscription activated.
| Another year of free McAfee internet security subscription |
Saturday, January 3, 2015
Hands on hacking - Windows 8.1 Elevation of Privilege vulnerability
Windows-Elevation of Privilege vulnerability in ahcache.sys/NtApphelpCacheControl, reported by the Google project Zero team is now all over in news. So, i thought to try it on my Windows 8.1 and let's see if the provided exploit works or not, and how to verify it ;)
Below are the steps taken directly from the report, and we will be going to execute it one by one and see how it works
Let's Start the test
You may wonder how to check if this is actually worked and calc.exe application is started in elevated mode, so here is how you can check :)
Below are the steps taken directly from the report, and we will be going to execute it one by one and see how it works
1) Put the AppCompatCache.exe and Testdll.dll on disk 2) Ensure that UAC is enabled, the current user is a split-token admin and the UAC setting is the default (no prompt for specific executables). 3) Execute AppCompatCache from the command prompt with the command line "AppCompatCache.exe c:\windows\system32\ComputerDefaults.exe testdll.dll". 4) If successful then the calculator should appear running as an administrator. If it doesn't work first time (and you get the ComputerDefaults program) re-run the exploit from 3, there seems to be a caching/timing issue sometimes on first run.
Let's Start the test
- Download the exploit files from this link
- As per the step #2 from report, make sure your currently logged in user is
- split-user token and UAC setting is set to default [ (i)-You should be an administrator, (ii)- Right click on calc.exe and select run as Administrator - an UAC pop up should be displayed ]
- Now navigate to downloaded folder poc\bin on command line and execute the below command:
- AppCompatCache.exe c:\windows\system32\ComputerDefaults.exe testdll.dll
- Now you should see calc.exe (calculator) running in elevated administrator mode and that's also without any asking for any UAC pop up confirmation from logged in user :\
Bypassing UAC using the exploit code (elevation of privilage)
You may wonder how to check if this is actually worked and calc.exe application is started in elevated mode, so here is how you can check :)
- Open the Task Manager > Navigate to Details tab > Right click on columns > click on 'Select Columns' > tick the 'Elevated' column and click on OK
Adding elevated column in Task Manager process details tab - once the 'elevated' column is added, you can see our calc.exe application is started as Administrator.
checking a process Elevated status
PS : If you like to go in the bug report detail you can check it here https://code.google.com/p/google-security-research/issues/detail?id=118
Subscribe to:
Posts (Atom)
AWS Certified Solutions Architect Associate - AWS Introduction - Questions
All the Best !!! Show Result !! Try Again !! ×
-
All the Best !!! Show Result !! Try Again !! ×
-
// Store you current window handle in a String variable. String parentWindow = driver.getWindowHandle(); // Click on the the p...
-
In my post i have used mailserver.com just for example you need to use an real time mail server for yourself. Why not try on your org ema...



