Tuesday, November 19, 2019

Create a Docker image by modifying existing images

There are two ways to create a new Docker image, and they are shown below:
- Create images by modifying existing images
- Create images by utilizing Dockerfiles

This document is to demonstrate how to create images by modifying existing images (P.S.: The following example shows how to modify an existing image named httpd and save it as a new image named demonalex/httpd:2)
#systemctl start docker
#docker run -it httpd /bin/bash
After modifying the image, execute the following commands:
#docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
884fa8ecd4bd        httpd               "/bin/bash"         8 minutes ago       Up 8 minutes        80/tcp   hardcore_aryabhata
#docker commit 884fa8ecd4bd demonalex/httpd:2
#docker images|grep httpd
demonalex/httpd                   2                   a6a8c482adec        41 seconds ago      205MB
httpd                             latest              19459a872194        2 months ago        154MB
#docker run -it demonalex/httpd:2 /bin/bash

Sunday, November 17, 2019

Docker File Import and Export

Export Image:
#docker save [OPTIONS] IMAGE [IMAGE...]
Example:
#docker save busybox > busybox.tar


Import Image:
#docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
Example:
#docker import /path/to/exampleimage.tgz


Load Image from Files:
#docker load [OPTIONS]
Example:
#docker load < busybox.tar.gz

Installing KVM at Kali Linux

#apt-get update
#apt install -y qemu-kvm libvirt0 virt-manager libguestfs-tools bridge-utils
#mkdir -p /var/lib/libvirt/iso
#cp ~/Downloads/*.iso /var/lib/libvirt/iso
#virt-manager

Sunday, October 27, 2019

[eJPT][spider]A simple web crawler/spider

#mkdir -p /tmp/test1
#cd /tmp/test1
#wget -r -l 5 http://URL/index.html; grep -nR -i keyword URL | tee ./report.txt

Friday, October 25, 2019

cgi_login3.pl

#!/usr/bin/perl -wT
use CGI qw(:standard);

$username='test1';
$password='test2';
$salt='173173';
$string=$username.$password;
$digest=crypt($salt,$string);

$the_cookie = cookie('test');

if($the_cookie ne $digest){
print "Content-type: text/html\n\n";
print "<script>alert('Your are not allowed to access this page!')</script>";
print "<script>window.history.back()</script>";
}else{
print "Content-type: text/html\n\n";
print start_html("Authenticated");
print <<EOF;
You have successfully logged into the system!<br>
EOF
print end_html;
}

cgi_login2.pl

#!/usr/bin/perl -wT
use CGI qw(:standard);

$username='test1';
$password='test2';
$salt='173173';
$string=$username.$password;
$digest=crypt($salt,$string);

$user = param('username');
$pass = param('password');

if(($user eq $username) && ($pass eq $password)){
$cookie = cookie(-name => 'test', -value => "$digest");
print redirect(-url => 'cgi_login3.pl', -cookie => $cookie);
}elsif((defined($user)) || (defined($pass))){
print "Content-type: text/html\n\n";
print "<script>alert('The username or password is wrong!')</script>";
print "<script>window.history.back()</script>";
}else{
;
}

cgi_login1.pl

#!/usr/bin/perl -wT
use CGI qw(:standard);

print header;
print start_html("Login");

print <<EndHTML;
<form action="cgi_login2.pl" method="POST">

Please enter your login name and password.<br>
username: <input type="text" name="username" size=10><br>
password: <input type="password" name="password" size=10><p>

Be sure you have cookies turned on in your browser.<p>

<input type="submit" value="Log In">

</form>
EndHTML

print end_html;