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.

  1. First you should be logged in to Jenkins interface as Administrators, so you should see 'Manage Jenkins' link on the left side options.
  2. Click on the 'Manage Jenkins', to navigate to 'Manage Jenkins' page. 'Configure System' option should be available
  3. Click on the 'Configure System' link, scroll down on 'Configure System' page, you should see the 'Email notifications' section.
  4. 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.

    Part II : Configure the email notification for the individual Jenkins job  

    1. 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'
    2. Under 'Post Build Actions', click on 'Add post build action' and select 'Email Notification' option.
    3. Now, when the 'Email notification' section visible. Provide the recipients email addresses and select other check box options per your requirement
    4. 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 : 

    1.  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\"
    2. 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 : 

    1. Try to rename your *.apk file to *.zip
    2. 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


    1. Open the Windows Registery editor from run.exe [ type regedit and ENTER ]
    2. Navigate to "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\winlogon"
    3. Set or create the following keys (DWORD, String, String)
      • AutoAdminLogon = "1"
      • DefaultUserName = Your user name
      • DefaultPassword = Your password
    4. 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 :-
    1. Close all the application and restart the System.
    2. Press F10 on system startup, to go to Bios Settings
    3. Enable the Virtual Settings from Bios Settings > System Configuration 
    4. 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 )

    1. Download and install the Python interpreter from https://www.python.org/downloads/ on your System. Python 2.7.9 version should be fine.
    2. Now download the Sqlmap zip file from http://sqlmap.org/
      • Unzip the sqlmap zip folder
      • Open the command prompt > navigate to sqlmap unzipped folder
      • Launch command "sqlmap.py"
        Install Sqlmap on windows
    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
    // 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:

    1. 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:
    1. Go to your svn checked project > right click > select 'upgrade the Working copy'
      1. This will upgrade the working copy and now you should be able to add/commit file easily.
    Easy Fix 2:
    1. Still after applying the fix above, issue is not fixed :(. You can try below then:
      1. Right click on the folder causing the issue.
      2. If on right click it does not have any svn 'upgrade the working copy'
      3. Then go under the folder delete the ".svn" folder completely
      4. 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.
    McAfee trial period expired
    Simple 2 step to extend the trial period and get free subscription :)

    1. 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
    2.  Close the McAfee and start again. and Bingooooo !!!! free subscription activated
      McAfee free subscription activated.
    3. 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

    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

    1. Download the exploit files from this link
    2. 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 ]
    3. Now navigate to downloaded folder poc\bin on command line and execute the below command:
      • AppCompatCache.exe c:\windows\system32\ComputerDefaults.exe testdll.dll
    4. 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
    Thank you :)
    
    
    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

    
    

    Running Selenium Webdriver tests on Internet Explorer browser

    So finally added support to execute tests on Internet Explorer browser also in my github project https://github.com/lalit-k/selenium-java-tests.

    3 Simple steps to add Internet Explorer support in Selenium Webdriver project:
    1. Download the IEDriverServer.exe , you can download the latest version from http://selenium-release.storage.googleapis.com/index.html for your target operating system.[download url may change, you can google latest if it changes]
    2. Extract the IEDriverServer.exe from the downloaded zip, and place in your project resources folder.
      IEDriverServer.exe
    3. Now, go to the Driver script where you are initializing the IEDriverServer and add the below code line to initialize the IEDriverServer.
    
    System.setProperty("webdriver.ie.driver", <full system path of the IEDriverServer.exe. Example: c:\tests\resources\IEDriverServer.exe>);
    WebDriver driver = new InternetExplorerDriver();
    

    Tip : you can use the "System.getProperty("user.dir");" to get the current working directory and then append the path to IEDriverServer.exe
    System.getProperty("user.dir")
    You can also view the complete code changes for your reference at https://github.com/lalit-k/selenium-java-tests/commit/d1dc4cd3f878d64a4119fc0d6297df026a07cf5a

    Running Selenium Webdriver tests on Google Chrome browser

    Few months back i had added the support to execute tests on Google Chrome browser in my github project https://github.com/lalit-k/selenium-java-tests , so i thought to write it down how you can do the same if needed in your project.

    3 Simple steps to add Google Chrome support in Selenium Webdriver project:
    1. Download the ChromeDriver.exe , you can download the latest version from http://chromedriver.storage.googleapis.com/index.html for your target operating system.[download url may change, you can google latest if it changes]
    2. Extract the chromedriver.exe from the downloaded zip, and place in your project resources folder.
      Add Chromedriver.exe
    3. Now, go to the Driver file where you are initializing the ChromeDriver and add the below code line to initialize the ChromeDriver.
    
    System.setProperty("webdriver.chrome.driver", <full system path of the chromedriver.exe. Example: c:\tests\resources\chromedriver.exe>);
    WebDriver driver = new ChromeDriver();
    

    Tip : you can use the "System.getProperty("user.dir");" to get the current working directory and then append the path to chromedriver.exe


    System.getProperty("user.dir")


    You can also view the complete code changes for your reference at https://github.com/lalit-k/selenium-java-tests/commit/01cda755f72918a417b7b0cded1b2db4c387eb70

    Add Facebook popup Like box on your blog


    When you come first time on this blog you must have seen a Facebook Like pop up box. Well that is just a few lines of JavaScript code embedded in the blog template.

    So, i thought it to share with you guys if you like to add on your blogs also :)

    Facebook popup Like box

    1. Open the your blog Layout Editor > Add a Widget > Select HTML/JavaScript widget.

    Configure Html/JavaScript widget

    2. Copy and paste the below code in the content section as shown in above image. [ Just change the page id to your own Facebook page/profile]

    
     <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' type='text/javascript'></script>
    
    <style>
    
    #fbox-background {
    
        display: none;
    
        background: rgba(0,0,0,0.8);
    
        width: 100%;
    
        height: 100%;
    
        position: fixed;
    
        top: 0;
    
        left: 0;
    
        z-index: 99999;
    
    }
    
    
    
    #fbox-close {
    
        width: 100%;
    
        height: 100%;
    
    }
    
    
    
    #fbox-display {
    
        background: #eaeaea;
    
        border: 5px solid #828282;
    
        width: 340px;
    
        height: 230px;
    
        position: absolute;
    
        top: 32%;
    
        left: 37%;
    
        -webkit-border-radius: 5px;
    
        -moz-border-radius: 5px;
    
        border-radius: 5px;
    
    }
    
    
    
    #fbox-button {
    
        float: right;
    
        cursor: pointer;
    
        position: absolute;
    
        right: 0px;
    
        top: 0px;
    
    }
    
    
    
    #fbox-button:before {
    
        content: "CLOSE";
    
        padding: 5px 8px;
    
        background: #828282;
    
        color: #eaeaea;
    
        font-weight: bold;
    
        font-size: 10px;
    
        font-family: Tahoma;
    
    }
    
    
    
    #fbox-link,#fbox-link a.visited,#fbox-link a,#fbox-link a:hover {
    
        color: #aaaaaa;
    
        font-size: 9px;
    
        text-decoration: none;
    
        text-align: center;
    
        padding: 5px;
    
    }
    
    </style>
    
    <script type='text/javascript'>
    
    //<![CDATA[
    
    jQuery.cookie = function (key, value, options) {
    
    // key and at least value given, set cookie...
    
    if (arguments.length > 1 && String(value) !== "[object Object]") {
    
    options = jQuery.extend({}, options);
    
    if (value === null || value === undefined) {
    
    options.expires = -1;
    
    }
    
    if (typeof options.expires === 'number') {
    
    var days = options.expires, t = options.expires = new Date();
    
    t.setDate(t.getDate() + days);
    
    }
    
    value = String(value);
    
    return (document.cookie = [
    
    encodeURIComponent(key), '=',
    
    options.raw ? value : encodeURIComponent(value),
    
    options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
    
    options.path ? '; path=' + options.path : '',
    
    options.domain ? '; domain=' + options.domain : '',
    
    options.secure ? '; secure' : ''
    
    ].join(''));
    
    }
    
    // key and possibly options given, get cookie...
    
    options = value || {};
    
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
    
    };
    
    //]]>
    
    </script>
    
    <script type='text/javascript'>
    
    jQuery(document).ready(function($){
    
    if($.cookie('popup_facebook_box') != 'yes'){
    
    $('#fbox-background').delay(5000).fadeIn('medium');
    
    $('#fbox-button, #fbox-close').click(function(){
    
    $('#fbox-background').stop().fadeOut('medium');
    
    });
    
    }
    
    $.cookie('popup_facebook_box', 'yes', { path: '/', expires: 7 });
    
    });
    
    </script>
    
    <div id='fbox-background'>
    
    <div id='fbox-close'>
    
    </div>
    
    <div id='fbox-display'>
    
    <div id='fbox-button'>
    
    </div>
    
    <iframe allowtransparency='true' frameborder='0' scrolling='no' src='//www.facebook.com/plugins/likebox.php?
    
    href=https://www.facebook.com/automatethebox&width=402&height=255&colorscheme=light&show_faces=true&show_border=false&stream=false&header=false'
    
    style='border: none; overflow: hidden; background: #fff; width: 339px; height: 200px;'></iframe>
    
    <div id="fbox-link">Powered by <a style="padding-left: 0px;" href="http://automatethebox.blogspot.com" rel="nofollow">AutomateTheBox</a></div>
    </div>
    </div>
    


    3. Save the Changes, and all Done :) ready to roll

    Friday, January 2, 2015

    ParseUser.logout() doesn't logs user out

    Recently working on a android app integrated with Parse and Facebook, i observed the issue that just calling the ParseUser.logout() does not clear the authenticated user token and logs in the user again on clicking on 'Log in as Facebook' even if user have logged out from the Facebook app also.


    goggled the solution, but found this is as Design :(


    So, still if you like to invalidate the facebook authentication token on ParseUser.logout(), you can do by adding a few lines of code shown below.


    #################Code Snippet#####################

    // Logout already logged in user from your android app.

    ParseUser.logout();


    // Check if user is logged in Facebook android app or not. If not clear the token information  explicitly.

     com.facebook.Session facebookSession= com.facebook.Session.getActiveSession();
            if (facebookSession== null) {
                facebookSession= new com.facebook.Session(this);
                com.facebook.Session.setActiveSession(facebookSession);
            }
            facebookSession.closeAndClearTokenInformation();

    #################Code Snippet#####################

    Now, when you click on 'Log in with Facebook', user will be taken to login screen and there you can then log in to your app as different user :)


    AWS Certified Solutions Architect Associate - AWS Introduction - Questions

    All the Best !!! Show Result !! Try Again !! ×