0

Global Outbound Route For Multi-Tenant FusionPBX

Posted by simon on 2020-07-29 in Guides |
  1. Create an outbound route as you normally would (on any of the domains)
  2. After it has been saved, go into the newly created outbound route
  3. Change the Domain from your selected domain to Global
  4. Change the Context from your selected domain to ${domain_name}
  5. Save the changes
  6. Go into Status -> SIP Status and click Flush Cache
  7. Finally you need to click either Rescan(if you have active calls) or Restart (if you have no active calls) on each of the listed SIP Profiles
  8. Celebrate you now have a global outbound route which work across ALL of your domains

1

Installing WMIC on Ubuntu 16.04

Posted by simon on 2017-07-17 in Guides |

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

5

Change Ricoh Printer Protocol To Connect To Windows Server

Posted by simon on 2016-11-25 in Guides |
  1. Open command prompt / terminal
  2. telnet into the ricoh printer telnet (IP)
    telnet 10.0.0.36
  3. 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>
  4. 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
    
  5. change client port to 445 using smb client port 445
    msh>smb client port 445
  6. change client auth level to 1 using smb client auth 1
    msh>smb client auth 1
  7. log off from the device using log off
    msh>log off
    Logout Maintenance Shell.
    Do you save configuration data? (yes/no/return) >
  8. When asked to save type yes
    Do you save configuration data? (yes/no/return) > yes
    Yes.
    Now, Save data.
    
    Connection closed by foreign host.
  9. Your ricoh copier should then restart and after a few mins the copier should be able to see a windows share correctly!

0

Installing WMIC on Ubuntu 14.04

Posted by simon on 2016-06-08 in Guides |

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

0

Setting up AutoSSH for Reverse SSH Forwarding

Posted by simon on 2015-07-20 in Guides |

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:

  1. Connect to Server A
  2. Run ssh-keygen -t rsa
  3. When asked Enter file in which to save the key Just Simple Click Enter and enter nothing
  4. When asked Enter passphrase (empty for no passphrase)
    and Enter same passphrase again Just again Simply Click Enter and enter nothing
  5. These Steps will have generated a public and private SSH key to use for your sign in
  6. 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:

  1. Run yum install openssh-clients autossh
  2. make the autossh folder mkdir /etc/autossh
  3. make your config file nano /etc/autossh/syslog
  4. 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"
    )
  5. when finished with nano, exit using CTRL+X and then Press Y to save and enter to save as the file you created
  6. now you need to create the autossh config file nano /etc/init.d/autossh
  7. 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
    
  8. you need to make the new file executable
    chmod a+x /etc/init.d/autossh
  9. you also need to make sure the script runs at start-up
    chkconfig –add autossh
  10. now you have finished setting it up, simply start the service /etc/init.d/autossh start
  11. Now to connect to the computer you simply run
    ssh (SERVER B user)@(SERVER B):(PORT)

0

How to Mount and Browse a LVM qcow2 Image

Posted by simon on 2015-06-29 in Guides |

This guide will show you how to mount a qcow2 image and also browse the qcow2 image if it is an LVM partition

  1. You need to add the nbd module to your machine
    modprobe nbd max_part=63
  2. You then need to mount the qcow2 image to the NDB device driver
    qemu-nbd -c /dev/nbd0 /path/to/image.qcow2
  3. 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 below

    Disk /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
  4. 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
  5. 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
  6. Now the LVM is found, only thing left to do is mount the LVM to a folder
  7. First make a folder mkdir /mnt/image
  8. Next mount the LVM by doing something like this:
    mount /dev/VolGroupName/LogVolName /mnt/image
  9. and you should be able to go to /mnt/image  and your files will be there!
  10. Once you have finished with the files, you need to unmount the folder:
    umount /mnt/image
  11. Also dont forget to make the LVM inactive:
    vgchange -an VolGroupName
  12. And finally detach the image from the computer all together:
    qemu-nbd -d /dev/nbd0

0

Setup ClamAV on CentOS 6 and Perform Daily Scans

Posted by simon on 2014-11-19 in Guides |

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

  1. Setup a CentOS 6 Machine, look for a guide yourselves, sorry 🙁
  2. Add the EPEL to the Machine
    1. i386
      rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
    2. x86_64
      rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
  3. Next install ClamAV
    yum install clamav clamav-db clamd
  4. Make the stuff folder mkdir /stuff
  5. 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"
    
    
  6. 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
    
    
  7. edit your crontab using crontab -e and add these files to the file
    1 0 * * * /stuff/0-freshclam
    40 0 * * * /stuff/1-clamscan
    
  8. And you are good to go 😀 🙂

Copyright © 2014-2021 Simon Smith All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.