Donation
I believe in helping the community with community projects, and this is why i created this post!
Below are all my different links to different donation methods available for people to help support me!
You can also leave me a comment or contact me, and I can provide my postal address to have items physically donated to myself if you wish!
Github: https://github.com/sponsors/si458
Amazon Wish List: https://www.amazon.co.uk/hz/wishlist/ls/68IO2WT4AC7L?ref_=wl_share
Paypal: https://www.paypal.com/donate/?hosted_button_id=K8QDU2U3Q5PJY
Buymeacoffee: https://www.buymeacoffee.com/si458
Ethereum: 0xBFb6e23390622B375952c9bA8170C18f15fB788E
Polygon: 0xBFb6e23390622B375952c9bA8170C18f15fB788E
Bitcoin: bc1qs47z9t9lzjc2pkc0g52f8lr770kpzuthrlyn3f
Install fping on Ubuntu 20.04
sudo apt-get install autoconf build-essential
git clone https://github.com/schweikert/fping
cd fping
./autogen.sh
./configure
make
sudo make install
sudo setcap cap_net_raw+ep /usr/local/sbin/fping
Global Outbound Route For Multi-Tenant FusionPBX
- Create an outbound route as you normally would (on any of the domains)
- After it has been saved, go into the newly created outbound route
- Change the
Domain
from your selected domain toGlobal
- Change the
Context
from your selected domain to${domain_name}
- Save the changes
- Go into
Status -> SIP Status
and clickFlush Cache
- Finally you need to click either
Rescan
(if you have active calls) orRestart
(if you have no active calls) on each of the listed SIP Profiles - Celebrate you now have a global outbound route which work across ALL of your domains
Installing WMIC on Ubuntu 16.04
Step 1 – Install building applications
sudo apt-get install autoconf make gcc libdatetime-perl build-essential g++ python-dev
Step 2 – Download the ‘wmic’ source
cd ~ wget http://www.opsview.com/sites/default/files/wmi-1.3.16.tar_.bz2
Step 3 – Untar the source
tar -xvf wmi-1.3.16.tar_.bz2
Step 4 – Go into the directory
cd wmi-1.3.16
Step 5 – Edit Samba/source/pidl/pidl and remove Line 583
nano Samba/source/pidl/pidl remove Line 583 (not sure how to do it short hand)
Step 6 – Compile and grab a butty as will take a few minutes
sudo sh -c "ulimit -n 100000 && export ZENHOME=/usr && make \"CPP=gcc -E -ffreestanding\" "
Step 7 – Move binary into /bin
sudo cp Samba/source/bin/wmic /bin
Step 8 – Test wmic
#Test it wmic --workgroup=DOMAIN --user=USER --password=PASSWORD //SERVER.DOMAIN.COM "SELECT * FROM Win32_ComputerSystem" #Output should be similar to this: CLASS: Win32_OperatingSystem BootDevice|BuildNumber|BuildType|Caption|CodeSet|CountryCode|CreationClassName|CSCreationClassName|CSDVersion|CSName|CurrentTimeZone|Debug|Description|Distributed|EncryptionLevel|ForegroundApplicationBoost|FreePhysicalMemory|FreeSpaceInPagingFiles|FreeVirtualMemory|InstallDate|LargeSystemCache|LastBootUpTime|LocalDateTime|Locale|Manufacturer|MaxNumberOfProcesses|MaxProcessMemorySize|Name|NumberOfLicensedUsers|NumberOfProcesses|NumberOfUsers|Organization|OSLanguage|OSProductSuite|OSType|OtherTypeDescription|PAEEnabled|PlusProductID|PlusVersionNumber|Primary|ProductType|QuantumLength|QuantumType|RegisteredUser|SerialNumber|ServicePackMajorVersion|ServicePackMinorVersion|SizeStoredInPagingFiles|Status|SuiteMask|SystemDevice|SystemDirectory|SystemDrive|TotalSwapSpaceSize|TotalVirtualMemorySize|TotalVisibleMemorySize|Version|WindowsDirectory \Device\HarddiskVolume1|3790|Uniprocessor Free|Microsoft(R) Windows(R) Server 2003, Enterprise Edition|1252|1|Win32_OperatingSystem|Win32_ComputerSystem||WIN2003-VM-HS|120|False||False|168|2|779280|2348260|3127540|20121101081525.000000+120|1|20121101090258.411875+120|20121105103817.505000+120|0409|Microsoft Corporation|4294967295|2097024|Microsoft Windows Server 2003 Enterprise Edition|C:\WINDOWS|\Device\Harddisk0\Partition1|5|46|4|Sintrex Integration Services (Pty) Ltd|1033|274|18|(null)|False|(null)|(null)|True|3|0|0|Test User|69763-011-6394922-43753|0|0|2527020|OK|274|\Device\HarddiskVolume1|C:\WINDOWS\system32|C:|0|3575072|1048052|5.2.3790|C:\WINDOWS
That’s it, it should work now from anywhere
Change Ricoh Printer Protocol To Connect To Windows Server
- Open command prompt / terminal
- telnet into the ricoh printer
telnet (IP)
telnet 10.0.0.36
- Login with the default admin username and password (admin – NO PASSWORD)
RICOH Maintenance Shell. User access verification. login:admin Password: User access verification ... OK. RICOH Aficio MP C3002 Network Control Service Ver. 11.103 Copyright (C) 1994-2015 Ricoh Co.,Ltd. All rights reserved. msh>
- check current setting of smb using
smb
msh>smb Workgroup Name : WORKGROUP Computer Name : Comment : Notification : Off Protocol : IPv4 Client Port : 139 Client Auth Level : 0 Client WSD Browse : Off
- change client port to 445 using
smb client port 445
msh>smb client port 445
- change client auth level to 1 using
smb client auth 1
msh>smb client auth 1
- log off from the device using
log off
msh>log off Logout Maintenance Shell. Do you save configuration data? (yes/no/return) >
- When asked to save type
yes
Do you save configuration data? (yes/no/return) > yes Yes. Now, Save data. Connection closed by foreign host.
- Your ricoh copier should then restart and after a few mins the copier should be able to see a windows share correctly!
Installing WMIC on Ubuntu 14.04
Step 1 – Install building applications
sudo apt-get install autoconf make gcc
Step 2 – Download the ‘wmic’ source
cd ~/Downloads wget http://www.openvas.org/download/wmi/wmi-1.3.14.tar.bz2
Step 3 – Untar the source
tar -xvf wmi-1.3.14.tar.bz2
Step 4 – Go into the directory
cd wmi-1.3.14
Step 5 – Compile and grab a butty as will take a few minutes
sudo make "CPP=gcc -E -ffreestanding"
Step 6 – Test wmic
#Test it wmic --domain=DOMAIN --user=USER --password=PASSWORD //SERVER.DOMAIN.COM "SELECT * FROM Win32_ComputerSystem" #Output should be similar to this: CLASS: Win32_OperatingSystem BootDevice|BuildNumber|BuildType|Caption|CodeSet|CountryCode|CreationClassName|CSCreationClassName|CSDVersion|CSName|CurrentTimeZone|Debug|Description|Distributed|EncryptionLevel|ForegroundApplicationBoost|FreePhysicalMemory|FreeSpaceInPagingFiles|FreeVirtualMemory|InstallDate|LargeSystemCache|LastBootUpTime|LocalDateTime|Locale|Manufacturer|MaxNumberOfProcesses|MaxProcessMemorySize|Name|NumberOfLicensedUsers|NumberOfProcesses|NumberOfUsers|Organization|OSLanguage|OSProductSuite|OSType|OtherTypeDescription|PAEEnabled|PlusProductID|PlusVersionNumber|Primary|ProductType|QuantumLength|QuantumType|RegisteredUser|SerialNumber|ServicePackMajorVersion|ServicePackMinorVersion|SizeStoredInPagingFiles|Status|SuiteMask|SystemDevice|SystemDirectory|SystemDrive|TotalSwapSpaceSize|TotalVirtualMemorySize|TotalVisibleMemorySize|Version|WindowsDirectory \Device\HarddiskVolume1|3790|Uniprocessor Free|Microsoft(R) Windows(R) Server 2003, Enterprise Edition|1252|1|Win32_OperatingSystem|Win32_ComputerSystem||WIN2003-VM-HS|120|False||False|168|2|779280|2348260|3127540|20121101081525.000000+120|1|20121101090258.411875+120|20121105103817.505000+120|0409|Microsoft Corporation|4294967295|2097024|Microsoft Windows Server 2003 Enterprise Edition|C:\WINDOWS|\Device\Harddisk0\Partition1|5|46|4|Sintrex Integration Services (Pty) Ltd|1033|274|18|(null)|False|(null)|(null)|True|3|0|0|Test User|69763-011-6394922-43753|0|0|2527020|OK|274|\Device\HarddiskVolume1|C:\WINDOWS\system32|C:|0|3575072|1048052|5.2.3790|C:\WINDOWS
That’s it, it should work now from anywhere
Setting up AutoSSH for Reverse SSH Forwarding
Autossh is a brilliant little application I discovered and it has helped me access servers that are behind NAT firewalls
Basically, Server A connects to a Server B in the cloud using SSH public keys, and asks Server B to forwards a port to the local SSH port on Server A
SETUP SSH KEYS TO BE USED:
- Connect to Server A
- Run ssh-keygen -t rsa
- When asked Enter file in which to save the key Just Simple Click Enter and enter nothing
- When asked Enter passphrase (empty for no passphrase)
and Enter same passphrase again Just again Simply Click Enter and enter nothing - These Steps will have generated a public and private SSH key to use for your sign in
- Run ssh-copy-id (USER)@(SERVER B) and when asked about RSA key fingerprint, Just Simply enter YES and enter the user’s password, and the keys will be copied to Server B
SETUP AUTOSSH:
- Run yum install openssh-clients autossh
- make the autossh folder mkdir /etc/autossh
- make your config file nano /etc/autossh/syslog
- when nano is open you need to paste in this config and change it to your requirements
# Check connection every 10 seconds, and after 3 tries (30 seconds), drop and # let autossh re-connect. ServerAliveInterval="10" ServerAliveCountMax="3" StrictHostKeyChecking="no" LocalUser="root" IdentityFile="~/.ssh/id_rsa" RemoteUser="(USER)" RemoteHost="(SERVER)" RemotePort="22" # Array of ports to be forwarded: # # Example: Forward port 3307, listening on 127.0.0.1 on the remote side, to # 127.0.0.1 port 3306 on the local side. Forward port 8081, listening on # 127.0.0.1 on the local side, to 10.100.1.60 port 80 on the remote side. # ForwardPort=( "R 127.0.0.1:(PICK PORT NUMBER):127.0.0.1:22" )
- when finished with nano, exit using CTRL+X and then Press Y to save and enter to save as the file you created
- now you need to create the autossh config file nano /etc/init.d/autossh
- paste in this config file, and when finished, exit using CTRL+X and then Press Y to save and enter to save as the file you created
#!/bin/bash # # autossh . Startup script for autossh # chkconfig: 2345 25 40 # description: Maintain persistent SSH tunnels # processname: autossh # pidfile: /var/run/autossh.pid # Copyright 2012 - Jean-Sebastien Morisset - http://surniaulula.com/ # # http://surniaulula.com/2012/12/10/autossh-startup-script-for-multiple-tunnels/ # # This script is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation; either version 3 of the License, or (at your option) any later # version. # # This script is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details at http://www.gnu.org/licenses/. # Changelog: # # 2013/06/21 - Reset the $forward_list variable at the start() to prevent the # accumulation of ports for each config loop. Also added support for socks # proxies. Thanks to Chris for pointing out the issue in the comments. # Source function library . /etc/init.d/functions RETVAL=0 prog="autossh" autossh="/usr/bin/autossh" [ ! -d /var/run/$prog ] && mkdir -p /var/run/$prog start() { config="$1" cfname=`basename $config` forward_list="" # make sure we have a config file if [ ! -f "$config" ] then failure echo "$prog $cfname: $config missing" return 1 fi . $config # make sure all variables have been defined in config for var in \ ServerAliveInterval ServerAliveCountMax StrictHostKeyChecking \ LocalUser IdentityFile RemoteUser RemoteHost RemotePort do eval " if [ -z \$$var ] then failure echo \"$prog $cfname: $var variable empty\" return 1 fi " done if [ ${#ForwardPort[*]} -eq 0 ] then failure echo "$prog $cfname: ForwardPort array empty" return 1 fi for fwd in "${ForwardPort[@]}" do case "$fwd" in D\ *:*|R\ *:*:*:*|L\ *:*:*:*) forward_list+="-$fwd " ;; *) failure echo "$prog $cfname: $fwd format unknown" return 1 ;; esac done # define the pidfile variable for autossh (created by autossh) # check if pidfile already exists -- don't start another instance if pidfile exists AUTOSSH_PIDFILE="/var/run/$prog/$cfname.pid" if [ -e $AUTOSSH_PIDFILE ] then failure echo "$prog $cfname: $AUTOSSH_PIDFILE already exists" return 1 fi echo -n "Starting $prog $cfname: " # before switching-users, make sure pidfile is created and user has write permission touch $AUTOSSH_PIDFILE chown $LocalUser $AUTOSSH_PIDFILE # start autossh as the user defined in the config file # the pidfile must be re-defined in the new environment su - $LocalUser -c " AUTOSSH_PIDFILE=$AUTOSSH_PIDFILE; AUTOSSH_PORT=0; export AUTOSSH_PIDFILE AUTOSSH_PORT; $autossh -q -N -p $RemotePort \ -i $IdentityFile \ -o ServerAliveInterval=$ServerAliveInterval \ -o ServerAliveCountMax=$ServerAliveCountMax \ -o StrictHostKeyChecking=$StrictHostKeyChecking \ $forward_list $RemoteUser@$RemoteHost -f;" # check to make sure pidfile was created if [ ! -f $AUTOSSH_PIDFILE ] then failure echo "`basename $AUTOSSH_PIDFILE` not created" return 1 fi success echo touch /var/lock/subsys/$prog } stop() { config="$1" # if no config names (on the command-line), stop all autossh processes if [ -z "$config" ] then echo -n "Stopping all $prog: " killproc $autossh RETVAL=$? echo if [ $RETVAL -eq 0 ] then rm -f /var/lock/subsys/$prog rm -f /var/run/$prog/*.pid fi else cfname="`basename $config`" pidfile="/var/run/$prog/$cfname.pid" if [ ! -f $pidfile ] then failure echo "$prog $cfname: $pidfile missing" return 1 else echo -n $"Stopping $prog $cfname: " killproc -p "/var/run/$prog/$cfname.pid" "$prog $cfname" RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/run/$prog/$cfname.pid fi fi return $RETVAL } # save the action name, and shift the command-line array # all remaining command-line arguments could be config names action="$1" shift case "$action" in start) if [ -z "$1" ] then # if no config names on the command-line, start all /etc/autossh/ configs found for config in `echo /etc/$prog/${cfname:='*'}` do $action $config; done else # start only the config files specified on the command-line for cfname in "$@" do $action /etc/$prog/$cfname; done fi ;; stop) if [ -z "$1" ] then # if no config names on the command-line, stop all autossh processes $action else # stop only the config files specified on the command-line for cfname in "$@" do $action /etc/$prog/$cfname; done fi ;; restart) # re-execute this script, with the stop and start action names instead $0 stop "$@" $0 start "$@" ;; status) if [ -z "$1" ] then # if no config names on the command-line, show all autossh pids status $autossh RETVAL=$? else # only show the status of config files specified on the command-line for cfname in "$@" do config="/etc/$prog/$cfname" # if the config file is missing, echo an error message if [ -f $config ] then cfname="`basename $config`" pidfile="/var/run/$prog/$cfname.pid" # if the pidfile is missing, echo an error message if [ -f $pidfile ] then status -p "$pidfile" "$prog $cfname" RETVAL=$? else echo "$pidfile missing" RETVAL=1 fi else echo "$config missing" RETVAL=1 fi done fi ;; *) echo "Usage: $0 {start|stop|restart|status} {config names...}" RETVAL=1 ;; esac exit $RETVAL
- you need to make the new file executable
chmod a+x /etc/init.d/autossh
- you also need to make sure the script runs at start-up
chkconfig –add autossh - now you have finished setting it up, simply start the service /etc/init.d/autossh start
- Now to connect to the computer you simply run
ssh (SERVER B user)@(SERVER B):(PORT)
How to Mount and Browse a LVM qcow2 Image
This guide will show you how to mount a qcow2 image and also browse the qcow2 image if it is an LVM partition
- You need to add the nbd module to your machine
modprobe nbd max_part=63
- You then need to mount the qcow2 image to the NDB device driver
qemu-nbd -c /dev/nbd0 /path/to/image.qcow2
- You can now check for the partitions by using the following command
fdisk -l /dev/nbd0 and you should get a list like the one belowDisk /dev/nbd0: 34.4 GB, 34359738368 bytes 255 heads, 63 sectors/track, 4177 cylinders, total 67108864 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000064e8 Device Boot Start End Blocks Id System /dev/nbd0p1 * 2048 499711 248832 83 Linux /dev/nbd0p2 501758 67106815 33302529 5 Extended /dev/nbd0p5 501760 67106815 33302528 8e Linux LVM
- You next need to let the computer scan for the LVM volumn by using vgscan and you should get something similar to this following output below:
Reading all physical volumes. This may take a while... Found volume group "Multicraft-vg" using metadata type lvm2 Found volume group "pve" using metadata type lvm2
- Once scanned, you will then need to add the LVM to your computer and set as Active, this can be done by using vgchange -ay and you should get the similiar output as below:
2 logical volume(s) in volume group "Multicraft-vg" now active 4 logical volume(s) in volume group "pve" now active
- Now the LVM is found, only thing left to do is mount the LVM to a folder
- First make a folder mkdir /mnt/image
- Next mount the LVM by doing something like this:
mount /dev/VolGroupName/LogVolName /mnt/image
- and you should be able to go to /mnt/image and your files will be there!
- Once you have finished with the files, you need to unmount the folder:
umount /mnt/image
- Also dont forget to make the LVM inactive:
vgchange -an VolGroupName
- And finally detach the image from the computer all together:
qemu-nbd -d /dev/nbd0
Setup ClamAV on CentOS 6 and Perform Daily Scans
Hi All,
This post is about Setting up ClamAV on CentOS 6 and Performing Daily Scans of the Machine and being Alerted by email if anything is found
- Setup a CentOS 6 Machine, look for a guide yourselves, sorry 🙁
- Add the EPEL to the Machine
- i386
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
- x86_64
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
- i386
- Next install ClamAV
yum install clamav clamav-db clamd
- Make the stuff folder mkdir /stuff
- Edit /stuff/0-freshclam And add this content, not forgetting to set the variables to your requirements
#!/bin/sh # set the log file LOG_FILE="/var/log/clamav/freshclam.log" if [ ! -f "$LOG_FILE" ]; then touch "$LOG_FILE" chmod 644 "$LOG_FILE" chown clam.clam "$LOG_FILE" fi /usr/bin/freshclam \ --quiet \ --datadir="/var/lib/clamav" \ --log="$LOG_FILE"
- Edit /stuff/1-clamscan And add this content, not forgetting to set the variables to your requirements
#!/bin/bash NOW=$(date +"%d-%m-%Y") # email subject SUBJECT="VIRUS DETECTED ON `hostname`!!!" # Email To ? EMAIL="to@me.com" # Email From ? FROMEMAIL="alert@fromme.com" # Log location LOG=/var/log/clamav/scan-$NOW.log # SCAN WHICH FOLDERS SCAN="/" #SCAN="/|/bob/|/fred/" # IGNORE WHICH FOLDERS IGNORE="/sys/" #IGNORE="/sys/|/fred/|/bob/" # force remove of old log file `rm -f $LOG` check_scan () { # Check results. If there are any "Infected", we have a problem. if [ `tail -n 12 ${LOG} | grep Infected | grep -v 0 | wc -l` != 0 ] then EMAILMESSAGE=`mktemp /tmp/virus-alert.XXXXX` echo "To: ${EMAIL}" >> ${EMAILMESSAGE} echo "From: ${FROMEMAIL}" >> ${EMAILMESSAGE} echo "Subject: ${SUBJECT}" >> ${EMAILMESSAGE} echo "Importance: High" >> ${EMAILMESSAGE} echo "X-Priority: 1" >> ${EMAILMESSAGE} echo "`cat ${LOG}`" >> ${EMAILMESSAGE} `/usr/sbin/sendmail -f ${FROMEMAIL} -t < ${EMAILMESSAGE}` fi } clamscan -r ${SCAN} --exclude-dir=${IGNORE} --quiet --infected --log=${LOG} check_scan
- edit your crontab using crontab -e and add these files to the file
1 0 * * * /stuff/0-freshclam 40 0 * * * /stuff/1-clamscan
- And you are good to go 😀 🙂