Increase Number of users generated from your local machine

Number of user generated from your local machine depends on your local machine specs but what if you can generate more users with number of tricks.

1. Don’t use listners

Listners consumes a lot of memory to be able to display information and do the necessary calculations , the less listners you use the more memory is available to generate users.

Use Simple Data Wriiter to store all of your run data and after the execution is finished you can get all information you need from .jtl file created.

*We have an article explaining how to use Simple data writer , see the following link

https://thetesttherapist.com/2019/01/27/save-run-results-with-simple-data-writer-in-apache-jmeter

2. Increase Java Heap Size Limit

We’re going to change the amount of memory reserved to JMeter by default to a larger size which allow JMeter to generate more users but you cannot set the memory size to be > 80% of your total system memory

Here is the default value in APache JMeter 5 , the default value is 256m

Screen Shot 2019-02-17 at 12.28.56 PM

You can set a new value which is not larger than 80% of your system memory , JMeter will not lunch if you set a memory which is much higher than possible.

*You can change the heap size value when you edit ¬†jmeter.bat file and search for “set HEAP” in notepad or any other editor.

3. Use x64 JDK and Windows

With x64 Windows and JDK you can consume more memory and have a better memory management that will help you generate more users than before.

*With all the above tricks your machine specs cannot exceed a certain boundary related to your hardware , and unfortunately we cannot calculate precisely how much a machine with a specific specs can generate and also it is differ from test to test.But these tricks help you get the max out of your machine before thinking to add a new machine to generate more or move to the cloud.

Stop JMeter test run when reaching a specific number of requests

You want to execute a JMeter performance test but you don’t want to exceed a specific number of requests , is it possible?

Yes it is ūüôā

What if we can get the value of the current iteration and make a condition to stop the test when reaching a specific values. This can be done as the following

Create a basic JMeter test plan with the essential samplers and listeners

Test plan will have the following :

  1. Thread Group
  2. Http Sampler
  3. If controller
  4. Test Action Sampler
  5. Summary Report Listener

Thread Group run settings will be as the following :

Thread group settings is just an example you can use what is suitable to your test

We will put If controller and a test action as a child for it in the beginning of the test just under the Thread Group.

Everytime you call ${__counter(,)} you got the current iteration number.
in the above example we need to set a maximum of 300 requests (iterations).

“${__counter(,)}” >= 301

So why i put the condition operator to be >=301 because in case of concurrency it will be easier to check for number of iteration after you already finished your 300 iterations , give it a try if you put 300 the test will be stopped at the iteration number 299.

Test Action will be a child to the IF Controller

When the condition is true the Test Action will stop the test.

Then you have to add http request , in the example we used “https://en.wikipedia.org/wiki/Main_Page”

At the end add summary report to check the number of request and run the test

Summary

With IF Controller and Test Action you can limit your test execution maximum number of requests While you executing a duration based test with multiple threads.

Visual Studio – Web test Custom Plugins & Extraction Rules

What is web test plug-in ?

The Web performance test plug-in is run one time for every test iteration. In addition, if you override the PreRequest or PostRequest methods in the test plug-in, those request plug-ins will run before or after each request, respectively.

What is Extraction Rule ?

Extraction rules are similar to validation rules, but instead of just verifying data, they will extract the data and store the result in the Web test context.

The idea behind writing custom libraries

The idea is to extend the visual studio web test capability to suit your test conditions and requirements.

Functionalities not exist out of the box

1.Loops using parameter in the terminating value.

2.Get the number of occurrences from the context.

3.Using parameters in the extraction rule index.

Custom Plugins & Extraction Rules examples

Custom Plugins  
Loop Context Plugin  

Custom Extraction Rules  
GetTheNumberOfOccurrences  
RegExpExtractorWithContextIndex

Loop Context Plugin


ConditionRuleContextParameter : the parameter name of the web test loop.  ContextParameterTerminatingValue : the parameter name that holds the terminating value.

Get The Number Of Occurrences

Context Parameter Name : Parameter name which will hold the number of occurrences value.
MyRegularExpression : Regex (pattern) that you want to get its number of occurrences.

Reg ExpExtractor With Context Index

Context Parameter Name : Parameter name which will hold the extracted value.
MyIndex : Parameter name which hold the index value. MyRegularExpression : Regex (pattern) that will be extracted from context.

Code snippets

References

https://msdn.microsoft.com/enus/library/ms243191.aspx
https://msdn.microsoft.com/en-us/library/ms243179.aspx

Save Run results with “Simple Data Writer” in Apache JMeter

One of the things that any new person who is dealing with JMeter is facing that if you save a jmx project which is executed before the run results is not saved.

So if you didn’t know this you may lose your run results and you have to repeat again.

One of the best ways to save your run data is using “Simple Data Writer” it not only make you able to save your run data but also enable you to use the data file on any listner or graph you want or need.

Data Files

CSV is one of the file extensions you can use to save your run results as the following example.

savedatatable

In the above example the results table will be saved to a .CSV file which is good in case you want only the data shown in the table but if you want more the Simple data writter will be a better option.

What are JTL files?

JMeter can create text files containing the results of a test run.

These are normally called JTL files, as that is the default extension – but any extension can be used.

Simple Data Writer

simpledatawritter

 You can configure the results save configuration the more you save the more listners you can use.

simpledatawritterconf

I used to select them all , sometimes this leads to larger size data file but this is safer to use in different graphs and listners as i will show you later.

Lets add simple data writter to thread group and disable all the other listners and execute test as the following.

simpledatawritterwithfile

datafile

After the run is finished i’m going to open the jtl file in the following listners :

  • View Results Tree
  • Summary Report
  • Active Threads over time graph
  • Hits per second graph

viewresultsjtl

summaryreportjtl

activethreadsjtl

As shown above the results data saved using Simple Data Writer can be used in any of the default JMeter listners and also extra listners which can be added to JMeter in the feature , .JTL extension is the default saving extensions which can be re-saved to CSV file if needed , see the following Wiki Page

https://wiki.apache.org/jmeter/JtlFiles

 

 

WordPress Security testing using WP-Scan

Do not use the following instructions to exploit others websites / services , Usage of WP-Scan for attacking targets without prior mutual consent is illegal.

WordPress now powers 30 percent of the web, according to data from web technology survey firm W3Techs.

WordPress is important framework and as the aove statistics it is widely used thats why securing a web site based on WordPress framework is something obvious.

What is WP-Scan ?

WPScan is a free, for non-commercial use, black box WordPress vulnerability scanner written for security professionals and blog maintainers to test the security of their sites.

Installation

You can install it via Docker with the following commands :

docker pull wpscanteam/wpscan

Scan WordPress Site

Default Scan

docker run -it –rm wpscanteam/wpscan –url Website URL

screen shot 2019-01-12 at 1.16.09 pm

screen shot 2019-01-12 at 1.18.17 pm

Using default options with a good compromise between speed and accuracy. For example, the plugins will be checked passively but their version with a mixed detection mode (passively + aggressively). Potential config backup files will also be checked, along with other interesting findings.

Only Display Vulnerable Plugins

docker run -it –rm wpscanteam/wpscan –url Site URL –enumerate vp

screen shot 2019-01-12 at 1.28.00 pm

screen shot 2019-01-12 at 1.29.27 pm

Enumerate User Name

docker run -it –rm wpscanteam/wpscan –url Site URL –enumerate

screen shot 2019-01-12 at 1.33.51 pm

screen shot 2019-01-12 at 1.34.41 pm

Useful Links

WPScan Vulnerability Database

https://wpvulndb.com/

WPScan on GitHub

https://github.com/wpscanteam/wpscan

 

SQL Map

Do not use the following instructions to exploit others websites / services , Usage of SQL Map for attacking targets without prior mutual consent is illegal.

According to the Open Web Application Security Project (OWASP), injection attacks are first on the list of the top 10 web vulnerabilities. Diving into these, SQL injections are responsible for a big chunk of this. Exploitation of SQL injections is trivial.

SQL Map is an open source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws and taking over of database servers. It comes with a powerful detection engine, many niche features for the ultimate penetration tester and a broad range of switches lasting from database fingerprinting, over data fetching from the database, to accessing the underlying file system and executing commands on the operating system via out-of-band connections.

We’re going to use SQL Map in 2 examples one for testing a  Get request and the other for testing a POST request also listing some extra commands that will be useful in further steps.

1) Installation

  1. Download & install python if you don’t have it from the following link https://www.python.org/downloads/
  2. Download SQL Map from the following link
    http://sqlmap.org/
  3. Extract the Zip folder then we’re ready to start

2) Exploit Get Request

  1. Open command prompt in Windows as administrator
  2. Go to the extracted SQL Map folder
  3. Type the following command
    sqlmap.py -u “Target URL”
    as the following picture
    Inkedsqlmap_1_LI
  4. If the database engine is identified you have the choice to use the specific payloads for the identified db or use all the available payloads
    sqlmap_2
    sqlmap_3
  5. According to previous screen shots , SQL map identified the parameter “id” as a vulnerable parameter and also listed the used patterns and their types.

3) Exploit POST Request

In this case we need to capture / intercept the post request and save it to text file then use SQL Map to exploit it , you can use any HTTP interceptor like “Fiddler” or “BurpSuite” or use the developer tool of your browser as the following examples.

Fiddler

sqlmap_Fiddler

Chrome Dev Tools 

ChromeDevTools

Lets start.

  1. Go to “http://demo.testfire.net/default.aspx”
  2. Click “Sign in” link in the top right
  3. Use the following credentials to login
    User Name : admin , Password : admin
    before you sign in make sure you’re going to intercept the login request as the above examples
  4. Save the raw post request in .txt file and move it to SQL map folder root
  5. Type the following command to start the exploit
    sqlmap.py -r filename.txt
    Inkedsqlmap_post1_LI
    sqlmap_post2
     In this case we have 2 vulnerable parameters , you have to choose which parameter you want to continue testing with as the above screen shot.

4) Useful Commands

sqlmap.py -r filename.txt –dbs
When the session user has read access to the system table containing information about available databases, it is possible to enumerate the list of databases.

sqlmap.py -r filename.txt –dump-all
It is possible to dump all databases tables entries at once that the session user has read access on.

SQL Map usage Wiki
https://github.com/sqlmapproject/sqlmap/wiki/Usage

Get Max Number of User Concurrency in JMeter

In JMeter default lisnters some values are not provided by default and one of the examples is the max number of user concurrency which sometimes important if you’re executing a test which is not duration based.

In this article we’re going to execute a test with 200 users ramping 1 user each 2 sec and let’s see what is the max user concurrency we can get.

But first we need to install a plugin and add a listner as the following :

  1. install jmeter plugin manager from the link below
    https://jmeter-plugins.org/wiki/PluginsManager/
  2. After installation , open the plugin manager from jmeter and select the following plugin “3 Basic Graphs” from “Available Plugins” section
    Screen Shot 2018-07-14 at 11.52.10 AM
  3. ¬†Make sure that you have a new listner under called “Active Threads Over Time” as the following picture
    Screen Shot 2018-07-14 at 12.02.43 PM

Now everything is in place lets make a quick run.

we’re going to use this fake API website “http://jsonplaceholder.typicode.com/” in our test

Screen Shot 2018-07-14 at 12.10.07 PM

Screen Shot 2018-07-14 at 12.10.34 PM

Screen Shot 2018-07-14 at 12.12.04 PM

Let’s execute and see the graph results ūüėČ

Screen Shot 2018-07-14 at 12.19.43 PM

If we look at the graph above , we got a max of 1 concurrent user during the test run , so lets change the ramping up values and see the changes.

we will modify the thread group to be 200 threads / ramp-up Period : 50 as the following and execute again.

Screen Shot 2018-07-14 at 12.25.50 PM

Screen Shot 2018-07-14 at 12.27.09 PM

If we look at the graph above , in 2 times during the test we had more than 1 concurrent users. Because this is a simple http call with no business behind we got a smooth run and nearly constant results but in more real life test this graph will help you know the max number of concurrent users during your test.