In this case, I’ll show you how to get IP from domains. We will save the domains in the file, then, after calling the command, we will get a list of IP addresses along with the names of the domains from which we want to get the IP address.
re situations where we can benefit from generating arbitrary IP addresses in bash. In this case, the first octet situations where There are situations where we can benefit from generating arbitrary IP addresses in bash. In this case, the first octet situations where we can benefit from generating arbitrary IP addresses in bash. In this case, the first octet in bash. In this case, the first octet situations where we can benefit from generating arbitrary IP addresses in bash. In this case (224.*.*.* / 10.*.*.* / 127.*.*.* / 0.*.*.* / 192.168.*.* / 172.16.*.* / 172.31.*.*) is not generated. Of course, the script can be adapted to your needs.
In my opinion, one of the most important things about Linux is history. Thanks to it, we know what has been done in the system and we can quickly check what commands were executed in the system. When working on different systems it is very useful to use grep and use (ctrl + r) in the shell to quickly search the command history. However, to make it even more useful, we will try to enlarge the history to 10000 by default, it is 1000 command lines. We will also add a date that will be next to the command issued. If we want to run the history command, just:
Shell
1
$history
To enlarge the history and add a date when executing a given command, you should:
Finally, I would like to introduce a few more tricks that I mentioned, e.g. greping history:
Shell
1
$history|grepcp
Of course, you can use any other command instead of ‘cp’.
Mentioned useful way to search history is to use (ctrl + r). After pressing this combination, we can start writing any command. History will be searched. If we hold ctrl again and press kolena once ‘r‘ we will jump to the command above from the bottom. In my case, as you can see, this is the second command from the bottom, that is:
If you are interested in where the history is saved and in what form, you can view it or delete it from the file:
Shell
1
$vi~/.bash_history
If we accidentally use the wrong command on the system, it makes sense to remove it.
This time I will use Kali Linux it is a great distro for pentesters. After all, nothing prevents you from using another distribution, such as Debian Linux.
Sometimes we need to check the certificate issuance date. Nmap and curl are a very good tool for this. Both of these tools allow for advanced analysis of the SSL connection. Let’s try to check the certificate date with nmap:
Shell
1
$nmap-p443--script ssl-cert soban.pl
To be more precise, let’s leave the date and time alone:
Java Keytool is a command-line tool that is used for managing cryptographic keys, certificates, and keystores in Java-based applications. In Linux, Java Keytool is often used for managing SSL/TLS certificates and securing web applications that run on Java-based servers like Tomcat, GlassFish, and JBoss.
Some of the key features of Java Keytool in Linux include:
Generating key pairs: Java Keytool can be used to generate key pairs, which are used for encryption, decryption, and digital signatures.
Importing and exporting certificates: Java Keytool can import and export certificates, which are used for verifying the authenticity of digital signatures and ensuring secure communications.
Managing keystores: Java Keytool can create, modify, and delete keystores, which are containers for cryptographic keys and certificates.
Configuring SSL/TLS: Java Keytool can be used to configure SSL/TLS connections for Java-based web applications, which are essential for securing data communications.
Some of the most commonly used Java Keytool commands in Linux include:
keytool -genkeypair: This command is used to generate a new key pair.
keytool -import: This command is used to import a certificate into a keystore.
keytool -list: This command is used to list the contents of a keystore.
keytool -delete: This command is used to delete a key or certificate from a keystore.
Overall, Java Keytool is an important tool for managing cryptographic keys and certificates in Java-based applications in Linux, and it is essential for securing web applications and ensuring the privacy and integrity of sensitive information.
Before we begin make copy of old keystor like this:
This script helps to notify me by e-mail about the condition of the disk. Remember to indicate the disk accordingly – in this case it is “/dev/sda” and change the e-mail address from “soban@soban.pl” to your own. Save the script in “/root/checkbadsector.sh“:
The best way to check information about domain and DNS configuration is “whois” and “dig”. This tools can provide a lot of informations. Lets try use it. First we must check that package is installed. I have already installed “dig”:
Shell
1
2
# which dig
/usr/bin/dig
In debian, you can use “dpkg -S”
Shell
1
2
# dpkg -S /usr/bin/dig
dnsutils:/usr/bin/dig
if you don’t have it then you should install:
Shell
1
# apt install dnsutils
Now we can check “dig” in “soban.pl” domain:
The same case in “whois”:
Shell
1
2
# which dig
/usr/bin/dig
Check what package provide:
Shell
1
2
# dpkg -S /usr/bin/whois
whois:/usr/bin/whois
And if you don’t have it, then install:
The best way to check information about domain and DNS configuration is “whois” and “dig”. This tools can provide a lot of informations. Lets try use it. First we must check that package is installed. I have already installed “dig”:
Shell
1
2
# which dig
/usr/bin/dig
In debian, you can use “dpkg -S”
Shell
1
2
# dpkg -S /usr/bin/dig
dnsutils:/usr/bin/dig
if you don’t have it then you should install:
Shell
1
# apt install dnsutils
Now we can check “dig” on “soban.pl” domain:
The same case in “whois”:
Shell
1
2
# which dig
/usr/bin/dig
Check what package provide:
Shell
1
2
# dpkg -S /usr/bin/whois
whois:/usr/bin/whois
And if you don’t have it, then install:
Shell
1
# apt install whois
As you can see, the domain “soban.pl” is currently using cloudflare DNS – which I highly recommend.
Sometimes it is necessary to change the DNS name indication to a different IP address. As you can see in the example below, google.com currently points to:
To change google.com indication to, for example – 37.187.101.239, edit the file: “/etc/resolv.conf” as root:
Shell
1
2
# cat /etc/resolv.conf
google.com37.187.101.239
After making this change, the effect is as follows:
Windows as you see there is similar situation:
File must be edited as administrator “C:\Windows\System32\drivers\etc\hosts”:
A convenient way to maintain the test environment is automatic updating. However, remember to set the backup, e.g. the day before – I always set it like that in proxmoxe. The script that updates the Debian system looks like this:
Shell
1
2
3
4
5
6
# cat /root/update.sh
#!/bin/bash
apt-getupdate
apt-getupgrade-q-y
apt-getautoremove-y-q
rm-rf/var/cache/apt/archives/*.deb
You can download the script from:
Shell
1
2
$cd/root/
$wget https://soban.pl/bash/update.sh
The script cleans unnecessary deb files after the update. Keep in mind the permissions and capabilities of the script:
Shell
1
# chmod +x /root/update.sh
In crontab, I set the day after automatic backup in proxmoxe:
Shell
1
104**3/root/update.sh>/dev/null2>&1
Of course, the script can be added in the production environment, but it should not be added to the crontab.