Nagios DNS A record check

Domain adresini guncelleyip, 2 adet A kaydinin cevap verdiginin kontrolunu yapan nagios scripti.

#!/bin/bash
# a/b site a record dns check
cihdomain=www.vmninja.com
cihresult=`dig A $ggdomain +multiline +noall +answer +nocmd @8.8.8.8 | awk '/IN A ([[:digit:]]+\.){3}/{gsub(/\.$/,"",$1); print $1","$NF}' |grep -i 11`

if [[ "$cihresult" == *11* ]] 
    then 
                echo -e "a/b dns ok \n$cihresult"
                exit 2
        else
                echo -e "a/b dns not ok \n$cihresult"
                exit 0
fi

Port scan python script with nmap module

Python modülünü kullanarak bir port tarama aracı;

import nmap

def nmap_scan(target, ports=None):
scanner = nmap.PortScanner()
if ports:
scanner.scan(target, ports=ports)
else:
scanner.scan(target)

for host in scanner.all_hosts():
    print(f'Host: {host}')
    for proto in scanner[host].all_protocols():
        print(f'Protocol: {proto}')
        ports = scanner[host][proto].keys()
        for port in ports:
            state = scanner[host][proto][port]['state']
            print(f'Port: {port}\tState: {state}')

if name == 'main':
target_host = input("Enter the target IP address: ")
port_range = input("Enter the port range (e.g., '1-1000', or leave empty for default): ")
if port_range:
start_port, end_port = map(int, port_range.split('-'))
ports = f'{start_port}-{end_port}'
else:
ports = None
nmap_scan(target_host, ports)

Bu kod, nmap modülünü kullanarak daha gelişmiş bir port tarama aracı sağlar. nmap.PortScanner() sınıfını kullanarak bir tarama nesnesi oluşturulur ve scan() yöntemi hedef IP adresi ve (opsiyonel olarak) bir port aralığıyla çağrılır. Sonuçlar taranan portlar ve durumları hakkında bilgi içerir ve bu bilgiler ekrana yazdırılır.