Thursday, December 01, 2016

Proxy Enforcer

I developed this little utility while doing proxy migration project. This utility helps me to enforce the Windows proxy settings to IE.


You can add Proxy by clicking the "Add Proxy" button, which gives you the same configuration like Windows


Once your proxy setting is added to the list, highlight the proxy and click "Select Proxy" to enforce the selected proxy to your IE. The program will run on the TaskBar. 



Wednesday, November 16, 2016

Ubuntu File Finders

To find the Disk Usage:

#> sudo du -sx /* 2> /dev/null | sort -n

To deep dive

#> sudo du -sx /var/* 2> /dev/null | sort -n

To find files bigger than something

#> sudo find / -size +10M -ls

Wednesday, October 26, 2016

Windows 2012 R2 - File Backup

I need to backup my files running on Windows 2012 R2 to external drive. I also need this to be done in a regular basis and send me an email after the job done with the report.

First, I create a batch file, called backup.bat, with the content

@echo off
robocopy H:\Home V:\Home /MIR /R:1 /W:1 /LOG:V:\Home.txt
robocopy K:\Documents V:\Documents /MIR /R:1 /W:1 /LOG:V:\Documents.txt
copy /b V:\Documents.txt +V:\Home.txt V:\Backup.txt

The last line is joining the 2 log files into a single file, backup.txt

Schedule this daily with the Windows Scheduler, having an actions:

Start a Program: cmd.exe
Add arguments: /c D:\scripts\backup.bat

That bit is done for backup job.

Now, the email bit. I create a powershell script, called email.ps1, with the content:

 function sendMail{

     Write-Host "Sending Email"

     #SMTP server name
     $smtpServer = "smtprelay.domain.local"

     #Creating a Mail object
     $msg = new-object Net.Mail.MailMessage

     #Creating SMTP server object
     $smtp = new-object Net.Mail.SmtpClient($smtpServer)

     #Email structure 
     $msg.From = "backup@mydomain.id.au"
     $msg.ReplyTo = "backup@mydomain.id.au"
     $msg.To.Add("me@mydomain.id.au")
     $msg.subject = "Backup Email - Daily"
     $msg.body = "Backup Email - Daily"
     $attachment = New-Object System.Net.Mail.Attachment("V:\Backup.txt", 'text/plain')
     $msg.Attachments.Add($attachment)

     #Sending email 
     $smtp.Send($msg)
  
}

#Calling function

sendMail 

The email powershell script attach the backup.txt file and send it away
On the same schedule job created earlier, add a second action:

Start a Program: powershell
Add arguments: D:\scripts\email.ps1

Done. Second action will be executed after the 1st action is running and it will grab the log and attach it to the email.

Friday, September 30, 2016

Westpac CISO Award

I got the CISO Award!! It was a surprise for me who just started with Westpac Security team for 8 months.

Tuesday, September 06, 2016

Monday, August 01, 2016

OwnCloud Manual Upgrade

I adopted the below methods from upgrading Wordpress manually and tweak the process for manually upgrading OwnCloud:

Backup
Navigate to your OwnCloud location and run the following to backup your OwnCloud.

rsync -a owncloud/ owncloud.backup/

Download Latest OwnCloud 

wget https://download.owncloud.org/community/owncloud-9.1.1.tar.bz2

replace the link with the latest bz2 file.

Extract the Package

bzip2 -d owncloud-9.1.1.tar.bz2
tar xvf owncloud-9.1.1.tar

this creates "owncloud" directory

Copy the Updated Files

rsync -rtv new_path_version/owncloud/ old_path_version/owncloud/

this syncs any file that has been changed from the new location/version to the old location

Navigate to The Site

Load the site and it will ask you to upgrade the database. Don't do it over the UI, do it manually

Database Upgrade Manually

run the following command from the "owncloud" directory

To test the database upgrade:

sudo -u www-data php occ upgrade --dry-run -v

To execute the database upgrade:

sudo -u www-data php occ upgrade -v






Wednesday, July 13, 2016

Dynamic DNS for Ubuntu

I am using opendns.com to protect my network at home. My IP isn't static, so I need a way to update opendns.com with my IP if that changes.

I am running ubuntu, so let's start with installing ddclient

sudo apt-get install ddclient

and then edit ddclient.conf

sudo vi /etc/ddclient.conf

I use the following config

use=web, web=myip.dnsomatic.com
ssl=yes
server=updates.opendns.com
protocol=dyndns2
login=<open-dns-username>
password=<open-dns-password>
<open-dns-label>

Wednesday, June 22, 2016

Ubuntu Apt-Get Proxy

To have Ubuntu apt-get connection proxies via your proxy, do the following

sudo vi /etc/apt/apt.conf

Add the following line:

Acquire::http::Proxy "http://yourproxy.tld:port";

save and fire away

Monday, May 16, 2016

PowerShell - Mount BitLocker Encrypted VHD

If you have .VHD BitLocker encrypted files and would like to mount it using PowerShell:

$ss = Read-Host "Enter BitLocker Password:" -AsSecureString

Mount-VHD <path-to-VHD>\Example.VHD

#Check your disk manager which drive letter the volume is assigned to the VHD

Unlock-BitLocker -MountPoint <drive letter> -Password $ss


Monday, April 11, 2016

Windows 2012 R2 ISO to USB

Need to rebuild my drop-dead Windows 2012 R2 server.
There is no way to burn the 5.4GB ISO to my single layer 4.7GB DVD media.

So the only way is to USB boot it, here is how.

Format your USB drive - FAT32 ONLY. Make sure it is format with Master Boot Record scheme.
Plug in to your machine

Download your Windows 2012 R2 ISO file

Download Windows 7 USB/DVD Download Tool here

Install Windows 7 USB/DVD Download Tool

Run it and select your ISO and target your USB

Done

Wednesday, March 16, 2016

.NET Executing Assembly Location

During coding, if you want to reference another file, such as configuration file, text file or XML file that is located on the same location where your binary/library is you can use the following:''

string location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

Have fun coding :)

Sunday, February 07, 2016

UNIX Screen - Split Screen

You can do it in screen the terminal multiplexer.
  • To split vertically: ctrla then |.
  • To split horizontally: ctrla then S (uppercase one).
  • To un-split: ctrla then Q (uppercase one).
  • To switch from one to the other: ctrla then tab
Note: After splitting, you need to go into the new region and start a new session via ctrla then c before you can use that area.
EDIT, basic screen usage:
  • New terminal: ctrla then c.
  • Next terminal: ctrla then space.
  • Previous terminal: ctrla then backspace.
  • N'th terminal ctrla then [n](works for n∈{0,1…9})
  • Switch between terminals using list: ctrla then " (useful when more than 10 terminals)
  • Send ctrla to the underlying terminal ctrla then a.

Friday, January 29, 2016

Passed Cisco 300-320 Exam Today!

Had to sit on the Cisco 300-320 exam today to extend my Cisco certifications for another 3 years.
Officially still CCNP and CCDP