Penetration Testing Tools – (stored in one drive)
DDoS attack tools
LOIC
Link: https://github.com/NewEraCracker/LOIC
hping3
Github Links:
- https://www.kali.org/tools/hping3/#hping3
- https://github.com/NullHypothesis/hping3
- https://github.com/antirez/hping
slowloris
Github Link: https://github.com/gkbrk/slowloris
HOIC
Github Link: https://github.com/cybort/HOIC
XOIC
Github Link: https://github.com/StormRLS/XOIC
RUDYJS
Github Link: https://github.com/sahilchaddha/rudyjs
rudydos
Github Link: https://github.com/s0lst1c3/rudydos
Zed Attack Proxy (ZAP)
Website link: https://www.zaproxy.org/
The world’s most widely used web app scanner. Free and open source. Actively maintained by a dedicated international team of volunteers. A GitHub Top 1000 project.
*It is stored in one drive
Burp Suite – Application Security Testing Software – PortSwigger
*It is stored in one drive
John the Ripper
Github Link: https://github.com/openwall/john
*It is stored in one drive
Web application firewall
With APACHE
Building your own Web Application Firewall (WAF) requires a solid understanding of common web vulnerabilities and how to effectively filter and block malicious traffic. Since you’re using Apache, PHP (with Laravel), and MySQL, you can develop a basic WAF by integrating security checks into your web server and application architecture.
Steps to Build a Custom WAF:
1. Identify Key Security Threats
Focus on the OWASP Top 10 vulnerabilities, which include:
- SQL Injection
- Cross-Site Scripting (XSS)
- Cross-Site Request Forgery (CSRF)
- Remote File Inclusion (RFI)
- Local File Inclusion (LFI)
- Denial of Service (DoS)
- Security Misconfigurations
2. Implement Input Validation in Laravel
Laravel provides several security features, but enhancing them for WAF-level protection is important.
- Sanitize Input: Use Laravel’s built-in validation to sanitize user inputs.phpCopy code
$request->validate([ 'username' => 'required|alpha_num', 'email' => 'required|email', ]); - Escape Output: Ensure that all outputs are escaped to prevent XSS attacks.phpCopy code
{{ $user_input }} - Rate Limiting: Use Laravel’s rate-limiting middleware to prevent brute-force and DoS attacks.phpCopy code
Route::middleware('throttle:10,1')->group(function () { // Routes with limited access });
3. ModSecurity Integration with Apache
ModSecurity is a popular open-source WAF that works as an Apache module. Instead of starting from scratch, you can integrate ModSecurity and create custom rules specific to your application.
- Install ModSecurity: On Debian/Ubuntu:bashCopy code
sudo apt install libapache2-mod-security2 - Enable ModSecurity:bashCopy code
sudo a2enmod security2 sudo systemctl restart apache2 - Configure ModSecurity: You can customize the security rules by editing the ModSecurity configuration file (usually located at
/etc/modsecurity/modsecurity.conf). Add custom rules to filter specific malicious traffic relevant to your application.Example rule to block SQL injections:bashCopy codeSecRule ARGS "(union|select|from|information_schema)" "deny,status:403,id:1001,msg:'SQL Injection Detected'"
4. Custom PHP WAF Logic
You can implement your own request validation and filtering within Laravel or Apache’s PHP environment.
- SQL Injection Protection: Use Laravel’s query builder or Eloquent ORM to avoid raw SQL queries and prevent SQL injection.phpCopy code
$users = DB::table('users')->where('id', $id)->first(); - Custom Middleware for Filtering: Create middleware to filter and block malicious requests.phpCopy code
public function handle($request, Closure $next) { // Block requests with suspicious patterns if (preg_match('/<script>|SELECT|UNION|INSERT/i', $request->input())) { abort(403, 'Forbidden'); } return $next($request); }
5. Logging and Monitoring
- Set up logs to monitor and block repeated suspicious traffic: Use Laravel’s logging feature to track suspicious activities.phpCopy code
Log::channel('daily')->info('Potential attack detected from IP: ' . $request->ip()); - Consider using a database table to store and track attacks for further analysis.phpCopy code
Schema::create('waf_logs', function (Blueprint $table) { $table->id(); $table->string('ip_address'); $table->string('attack_type'); $table->timestamps(); });
6. Response Handling
- Block Requests: After detecting malicious patterns, respond with HTTP 403 or 400.phpCopy code
return response()->json(['error' => 'Forbidden'], 403); - Redirect: For failed validation attempts, redirect users or show an error page.phpCopy code
return redirect()->route('error.page')->withErrors('Suspicious activity detected');
7. Advanced Techniques
- Real-Time Traffic Analysis: Use libraries like Redis or Elasticsearch to store and analyze real-time traffic patterns.
- Machine Learning: Implement machine learning algorithms to detect anomaly-based attacks and prevent zero-day vulnerabilities.
8. Testing Your WAF
Once implemented, perform penetration testing using tools like:
- OWASP ZAP (Zed Attack Proxy)
- Burp Suite
- sqlmap (for SQL injection)
- Custom scripts to simulate various attacks (XSS, brute force, etc.).
By leveraging Apache, ModSecurity, and Laravel’s middleware, you can create a layered WAF system tailored to your needs.
For NGINX
Steps to Install ModSecurity with Nginx:
- Install Required Dependencies:
- You need to install ModSecurity (version 3) and its dependencies. The following commands work on Ubuntu/Debian systems:
sudo apt-get update sudo apt-get install libmodsecurity-dev git build-essential nginx - Download and Build ModSecurity:
- Download the ModSecurity source code and build it from source.
git clone https://github.com/SpiderLabs/ModSecurity cd ModSecurity git submodule init git submodule update ./build.sh ./configure make sudo make install - Download and Build ModSecurity Nginx Connector:
- Download the Nginx connector, which allows Nginx to communicate with ModSecurity.
git clone https://github.com/SpiderLabs/ModSecurity-nginx - Compile Nginx with ModSecurity:
- You need to compile Nginx from source with the ModSecurity connector. First, download the Nginx source code:
wget http://nginx.org/download/nginx-<version>.tar.gz tar -xzvf nginx-<version>.tar.gz cd nginx-<version>- Compile Nginx with the ModSecurity module:
./configure --add-module=../ModSecurity-nginx make sudo make install - Configure ModSecurity for Nginx:
- Edit the Nginx configuration file (usually located at
/etc/nginx/nginx.confor/usr/local/nginx/conf/nginx.conf). - Add the ModSecurity directive in the relevant server block:
server { listen 80; server_name example.com; modsecurity on; modsecurity_rules_file /etc/nginx/modsec/modsecurity.conf; } - Edit the Nginx configuration file (usually located at
- Download the OWASP Core Rule Set (CRS):
- OWASP CRS provides a set of default rules to protect against common web attacks.
git clone https://github.com/coreruleset/coreruleset /etc/nginx/modsec/- Enable the Core Rule Set by editing the
modsecurity.conffile:
Include /etc/nginx/modsec/coreruleset/crs-setup.conf Include /etc/nginx/modsec/coreruleset/rules/*.conf - Restart Nginx:
- After configuring ModSecurity, restart Nginx to apply the changes.
sudo systemctl restart nginx
Conclusion
ModSecurity is fully supported on Nginx via the ModSecurity Nginx Connector, which allows you to apply powerful security rules to your Nginx server. With this setup, you can protect your web applications from common web attacks, just like you would with Apache.
If you’re using Nginx as a reverse proxy or main web server, integrating ModSecurity gives you WAF capabilities, helping you secure your web applications.
Installing ESXi 6.0 in a Hyper-V Virtual Machine
One of the new features with Windows Server 2016 is the Nested Virtualization. It means that you can run a VM inside a Virtual Machine. So you also can run an ESXi inside a Hyper-V Virtual Machine. It can be useful only in a testing environment because it is really not supported in production!
Basically, to install ESXi in a Hyper-V Virtual Machine, below are the steps:
- Download and install PowerCLI
- Download ESXi-Customizer-PS. It is a PowerShell script that will simplify and automate the process of creating fully patched and customized ESXi installation ISOs using the VMware PowerCLI ImageBuilder module. You can download it from http://www.v-front.de/p/esxi-customizer-ps.html
- Create Hyper-V VM with a Legacy Network Adapter
- Configure the adapter with Mac Spoofing enabled
- Use the customizer to download and rebuild the ESXi ISO
- Mount the newly created ISO inside the Virtual Machine
- Download and run the “Enable-NestedVM.ps1” script. Download it from: https://github.com/Microsoft/Virtualization-Documentation/blob/master/hyperv-tools/Nested/Enable-NestedVm.ps1
- And then, you can install ESXI 6.0
The only prerequisites to run these steps is that you must have a Hyper-V Host running Windows Server 2016 or Windows 10 with an Intel processor with VT-x and EPT technology.
Preparing ESXi 6.0 ISO
Let’s start by downloading and installing PowerCLI. A few weeks ago, VMware published VMware PowerCLI on the PowerShell Gallery. So in this article, I will install VMware.PowerCLI 10.0.0.7895300 via the following PowerShell command. Don’t forget to open an elevated prompt:
PS> Install-Module -Name VMware.PowerCLI
Wait a moment until the installation finishes. Once the installation is done, you can run the customizer script:
The script will download the ESXi 6.0 ISO from the VMware online depot and customize it by injecting drivers:
- Use the –vft parameter to connect to the V-Front Online Depot
- Use net-tulip in order to load DECchip 21140 Ethernet driver inside the ISO. This driver allows running ESXi as a VM under Microsoft Hyper-V

Once the ISO is downloaded, you can check if the file exists in the current directory.
Creating the Virtual Machine
Now we can create the Virtual Machine for our ESXi. That’s pretty simple, you just need to create a 1st Gen Virtual Machine:
Click Next and:
- Enter a Virtual Machine name
- Browse to the location in which the Virtual Machine will be stored

Select the first choice “Generation 1” and click Next
Specify the amount of memory to allocate to this Virtual Machine
Don’t connect the network because we must remove the default adapter and then create a new one. The newly adapter will be a legacy adapter.
Select “Create a virtual hard disk”
Now you can mount the ESXi ISO file
Review the information and validate the wizard by clicking Finish
Ok now, I successfully created the ESXi VM but before starting this Virtual Machine, I must modify the settings.
Right-click the Virtual Machine and select “Settings”
Modify the number of virtual processors. I will configure 2 processors for this VM.
Then remove the default network adapter
Add a Legacy Network Adapter and connect to your Hyper-V Virtual Switch in order to communicate with the internet or with your LAN.
Enabling Nested Virtualization
This step is very simple, because we just need to run the “Enable-NestedVm.ps1” script:
Note: Don’t forget to enable Mac Address Spoofing.
Starting and configuring the ESXi Virtual Machine
Here is the final step. Start the Virtual Machine and add the following command to the boot options:
ignoreHeadless=TRUE
Wait a few seconds until the installation is finished. Once it’s done, your ESXi is installed in a Hyper-V
Virtual Machine and ready to be used.

Conclusion
Thanks to Windows Server 2016 and the Nested Virtualization, you can easily install ESXi in a Hyper-V Virtual Machine which is great to test a new ESXi version.
Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.
5 Tips to Boost the Performance of Your Apache Web Server
TIP #1: Always keep Apache updated to its latest version
It goes without saying that having the latest version of Apache installed is probably one of the first things you need to consider. As of November 19, 2015, the latest version of Apache available in the CentOS 7 repositories is 2.4.6, whereas in Debian’s is 2.4.10.
However, there may be a recent improvement or a bug fix that has been added to a newly-released stable version, which is then made available to download and install from source. Compilation and installation instructions are also provided here – just remember that if you choose this update method, you may want to back up your current configuration files / sites / virtual hosts as a precaution.
In any event, you can check your currently installed version as follows:
# httpd -v [On RedHat/CentOS based systems] # apache2 –v [On Debian/Ubuntu based systems]

As a rule of thumb, stick with the update method provided by the package manager of your chosen distribution (yum update httpd or aptitude safe-upgrade apache2, for CentOS or Debian, respectively) unless there is no other way. You can read the latest release notes in the Apache Documentation section in the Apache HTTP server Project website.
TIP #2: If you are using a Kernel older than 2.4, consider upgrading now
Why? Kernel versions 2.4 and above have the sendfile kernel system call enabled by default. That, in turn, facilitates high performance network file transfers (which are desired in the context of web server-client communications) and enables Apache to deliver static content faster and with lower CPU utilization by performing simultaneous read and send operations.
You can view your currently installed kernel with:
# uname -r
and compare it to the latest stable kernel in http://www.kernel.org (4.3 at the time of this writing).

Although it is a process not intended for beginners, upgrading your kernel is an interesting exercise to learn more about the internals of Linux.
TIP #3: Choose the Multi-Processing Module (MPM) that works best for your case
In practice, MPMs extend the modular functionality of Apache by allowing you to decide how to configure the web server to bind to network ports on the machine, accept requests from clients, and use children processes (and threads, alternatively) to handle such requests.
Beginning with version 2.4, Apache offers three different MPMs to choose from, depending on your needs:
- The
preforkMPM uses multiple child processes without threading. Each process handles one connection at a time without creating separate threads for each. Without going into too much detail, we can say that you will want to use this MPM only when debugging an application that uses, or if your application needs to deal with, non-thread-safe modules like mod_php. - The
workerMPM uses several threads per child processes, where each thread handles one connection at a time. This is a good choice for high-traffic servers as it allows more concurrent connections to be handled with less RAM than in the previous case. - Finally, the
eventMPM is the default MPM in most Apache installations for versions 2.4 and above. It is similar to the worker MPM in that it also creates multiple threads per child process but with an advantage: it causes KeepAlive or idle connections (while they remain in that state) to be handled by a single thread, thus freeing up memory that can be allocated to other threads. This MPM is not suitable for use with non-thread-safe modules like mod_php, for which a replacement such a PHP-FPM must be used instead.
To check the MPM used by your Apache installation, you can do:
# httpd -V
The image below show that this particular web server is using the prefork MPM.

To change this, you will need to edit:
# /etc/httpd/conf.modules.d/00-mpm.conf [On RedHat/CentOS based systems] # /etc/apache2/mods-available/<mpm>.load [On Debian/Ubuntu based systems]
Where <mpm> can be mpm_event, mpm_worker, or mpm_prefork.
and uncomment the line that loads the desired module like so:
LoadModule mpm_event_module modules/mod_mpm_event.so
Note: To make the event MPM work in Debian, you may have to install the libapache2-mod-fastcgi package from the non-free repositories.
Additionally, for CentOS you will need php-fpm (along with fcgi and mod_fcgid) whereas in Debian it’s called php5-fpm (along with apache2-mpm-event).
Last, but not least, restart the web server and the newly installed php-fpm (or php5-fpm) service:
On RedHat/CentOS
# systemctl restart httpd php-fpm && systemctl enable httpd php-fpm
On Debian/Ubuntu
# systemctl restart apache2 php5-fpm && systemctl enable apache2 php5-fpm
Although you can set Apache to use a specific MPM, that configuration can be overridden on a per-virtual host basis in the same fashion as indicated earlier.
Just drop the corresponding tags into the configuration file for each virtual host and you’re ready to go – but make sure you’re using one and only one MPM per vhost.
Finally, please note that regardless of your chosen distribution, php-fpm relies on the implementation of FastCGI, which is the reason why I recommended the additional package installations earlier.
For more details and examples on php-fpm and how it can along with the event MPM increase the performance of Apache, you should refer to the official documentation.
This is what I see after changing the default MPM from prefork to event in the same box shown in the previous image:

In CentOS 7, you will need to make sure that the http and https services are enabled through the firewall, and that the network interface(s) are properly added to the default zone.
For example:
# firewall-cmd --zone=internal --add-interface=tun6to4 # firewall-cmd --zone=internal --add-interface=tun6to4 --permanent # firewall-cmd --set-default-zone=internal # firewall-cmd --add-service=http # firewall-cmd --add-service=https # firewall-cmd --add-service=http --permanent # firewall-cmd --add-service=https --permanent # firewall-cmd --reload
The reason why I’m bringing this up is because I recently experienced an issue where the default firewalld configuration settings in a cloud VPS prevented php-fpm and Apache from processing php files.
As a basic test (I am sure you can think of more complicated or stressful ones), I will create a php file that checkes the existence of another file named test.php in the same directory of two CentOS 7 servers with the same hardware characteristics and load but with different MPM. One of them will use event and the other one will use prefork:

This is the php code that I’ve saved into a file named checkiffileexists.php:
<?php
$filename = 'test.php';
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
?>
Then we will run the Apache benchmark tool (ab) with 200 simultaneous requests until 2000 requests are completed:
# ab -k -c 100 -n 2000 localhost/checkiffileexists.php
Let’s run the test and compare the results. Pay attention to the performance statistics:

As you can see, the performance of the server with event is highly superior to its prefork counterpart in every aspect of this test.
TIP #4: Allocate RAM wisely for Apache
Perhaps the most critical hardware item to be taken into account is the amount of RAM allocated for each Apache process. While you cannot control this directly, you can restrict the number of child processes through the MaxRequestWorkers directive (formerly known as MaxClients in Apache 2.2), which will put limits on the RAM usage by Apache. Again, you can set this value on a per host or per virtual host basis.
To do this, you should take note of the average amount of RAM used by Apache, then multiply it by the number of MaxRequestWorkers, and that is the amount of memory that will be allocated for Apache processes. One thing you never want your web server to do is to begin using swap, as that will significantly decrease its performance. Thus, you should always keep the usage of RAM by Apache within the limits that you can afford and never rely on swap for it.
For example, the following block will restrict the number of simultaneous clients to 30. If more clients hit the host, they may experience a delay or a momentary failure that can be easily solved by refreshing the browser. While this may be considered undesirable, it is healthier for the server and in the long run, best for your site as well.
You can place this block inside /etc/httpd/conf/httpd.conf or /etc/apache2/apache2.conf, depending on whether you are using CentOS or Debian.
Please note that the same principle applies to all MPMs – I am using event here to continue with the concept outlined in the previous tip:
<IfModule mpm_event_module>
StartServers 3
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 30
MaxConnectionsPerChild 1000
</IfModule>
In any event, it is highly recommended that you refer to the Apache 2.4 docs to see which directives are allowed for your chosen MPM.
TIP #5: Know your applications
As a rule of thumb, you should not load any Apache modules that are not strictly needed for your application to work. This will require at least an overall knowledge of the applications running on your server, specially if you are a system administrator and there’s another team in charge of development.
You can list the currently loaded modules with:
# httpd -M [On RedHat/CentOS based systems] # apache2ctl -M [On Debian/Ubuntu based systems]
To unload / disable modules in CentOS, you will need to comment out the line that begins with LoadModule (either in the main configuration file or in an auxiliary one inside /etc/httpd/conf.modules.d.
On the other hand, Debian provides a tool called a2dismod to disable modules and is used as follows:
# a2dismod module_name
To enable it back:
# a2enmod module_name
In either case, remember to restart Apache for the changes to take effect.
Summary
In this article we have reviewed 5 tips that will help you tune the Apache web server and increase its performance. In addition, you should remember that optimization and performance without security is pointless, so you may want to refer to the install mod_pagespeed to improve webserver performance and Apache hardening tips article in Tecmint.com as well.
Compress a file using GZip and convert it to Base64 – and back – using C#
Sometimes you want to store a file in a database or even transfer stuff over the Internet through different protocols, maybe even to other platforms. In many of these cases the traditional methods simply wont do. Storing files in databases is usually made by sending the file as a blob to the database and it usually works out pretty good to, but in some cases you simply want a different structure. I often tend to end up in projects with several platforms and languages, this means XML or similar languages like JSON. Anyway binary data is out, you need a different way to transfer or store files. When it comes to files I recommend using GZip compression which is shipped as a standard with .NET.
If you are looking for a less complex compresson you should use gzdeflate and gzinflate.
Compressing a file
string fileName = @"c:\test.pdf"; byte[] file = File.ReadAllBytes(fileName); // Compress byte[] compress = Compress(file);
public static byte[] Compress(byte[] data)
{ using (var compressedStream = new MemoryStream()) using (var zipStream = new GZipStream(compressedStream, CompressionMode.Compress)) { zipStream.Write(data, 0, data.Length); zipStream.Close(); return compressedStream.ToArray(); } }
Encode the byte array
string encoded = base64_encode(compress);
public string base64_encode(byte[] data)
{ if (data == null) throw new ArgumentNullException("data"); return Convert.ToBase64String(data); }
The contents of “encoded” is your file but compressed and base64 encoded. You can take this string and send it through any protocol allowing strings. If we print the encoded string it looks something like this

Decode and Decompress
// Decode and decompress byte[] decoded = base64_decode(encoded); byte[] decompressed = Decompress(decoded); File.WriteAllBytes(@"c:\out.pdf", decompressed);
public static byte[] base64_decode(string encodedData) { byte[] encodedDataAsBytes = Convert.FromBase64String(encodedData); return encodedDataAsBytes; }
public static byte[] Decompress(byte[] data) { using (var compressedStream = new MemoryStream(data)) using (var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress)) using (var resultStream = new MemoryStream()) { var buffer = new byte[4096]; int read; while ((read = zipStream.Read(buffer, 0, buffer.Length)) > 0) { resultStream.Write(buffer, 0, read); } return resultStream.ToArray(); } }
Connect Laravel 5 with SQL Server
- Install SQL SERVER (2014 or higher)
- check PHP version
- got to https://github.com/Microsoft/msphpsql/releases and download for extension files for PHP according to OS
- extract extension files
- paste the files to PHP>ext directory
- now find php.ini file and edit it
- copy full name of the extensions such as for php7.1 version extensions are like “php_sqlsrv_71_ts.dll” and “php_pdo_sqlsrv_71_ts.dll”. now include those ext names in php.ini file like
extension=php_sqlsrv_71_ts.dll
extension=php_pdo_sqlsrv_71_ts.dll - now restart apache/httpd server
- go to SQL Server Configuration Manager => SQL Server Network Configuration => Protocals for SQLExpress/SQLServer
- Enable TCP/IP and got to TCP/IP properties => IP Address. Find “IP All” section and in the TCP Port write 1433. Then Apply and OK.
- Now test laravel application with credentials.
- The host name will be localhost or 127.0.0.1
Undefined function curl_init() in Laravel on PHP 7.* on Windows
copy libssh2.dll, ssleay32.dll, ssleay32.dll (that exists in your php directory) to “Apache24/bin” directory.
Setup Hosted Network on Ubuntu
Setup wireless card:
https://askubuntu.com/questions/55868/installing-broadcom-wireless-drivers
Share Wi-Fi with wired connection
3 Ways to Create Wifi Hotspot in Ubuntu 14.04 (Android Support)
Things to do after Laravel Installation
in a terminal run
sudo chgrp -R www-data storage
sudo chgrp -R www-data bootstrap/cache
