Sunday, February 08, 2015

Setting up the openvpn server ( again )

Lets install OpenVPN
apt-get install openvpn

Lets create the easy-rsa and copy some sample files over
cd /etc/openvpn
mkdir easy-rsa
cp -R /usr/share/doc/openvpn/examples/easy-rsa/2.0/* easy-rsa/

Lets clean the easy rsa folder first
cd easy-rsa
source ./vars
./clean-all

Lets build the CA
./build-ca

Lets build the server
./build-key-server server

Lets build the DH parameters
./build-dh

For each client
./build-key clientname

Lets make sure that ipv4_forward and iptables can jump here and there.
echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A POSTROUTING -s 10.9.8.0/24 -j SNAT --to-source

Lets save the IPtables
iptables-save > /etc/iptables.up.rules

Lets create the openvpn server config
nano /etc/openvpn/server.conf

port 1194
proto udp
dev tun

ca      /etc/openvpn/easy-rsa/keys/ca.crt    # generated keys
cert    /etc/openvpn/easy-rsa/keys/server.crt
key     /etc/openvpn/easy-rsa/keys/server.key  # keep secret
dh      /etc/openvpn/easy-rsa/keys/dh1024.pem

server 10.9.8.0 255.255.255.0  # internal tun0 connection IP
ifconfig-pool-persist ipp.txt

keepalive 10 120

comp-lzo         # Compression - must be turned on at both end
persist-key
persist-tun

status log/openvpn-status.log

verb 3  # verbose mode
client-to-client

cd /etc/openvpn
mkdir -p log/
touch log/openvpn-status.log

#This is needed if you want to route all traffic through the VPN
push "redirect-gateway def1 bypass-dhcp"

#Push down DNS just in case
push "dhcp-option DNS 8.8.8.8"

Restart the openvpn service and it should be up and running!

For the client config:
client
dev tun
port 1194
proto udp

remote VPNSERVER_IP 1194             # VPN server IP : PORT
nobind

ca ca.crt
cert clientname.crt
key clientname.key

comp-lzo
persist-key
persist-tun

verb 3


Copied from : https://wiki.debian.org/OpenVPN

Saturday, February 07, 2015

Email alert when SSH logged in!

cd /home/username/
nano .bashrc

Add this line last
echo 'ALERT - Root Shell Access (ServerName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d'(' -f2 | cut -d')' -f1`" your@yourdomain.com

EG:
ALERT - Root Shell Access (Database Replica) on: Thu Nov 28 16:59:40 IST 2013 tecmint pts/0 2013-11-28 16:59 (172.16.25.125)

Copied from: http://www.tecmint.com/get-root-ssh-login-email-alerts-in-linux/

Sunday, December 14, 2014

MYSQL Server - Root password cannot login how!

/etc/init.d/mysql stop

Create a text file
UPDATE mysql.user SET Password=PASSWORD('XXX') WHERE User='root';
FLUSH PRIVILEGES;

Start MySQL in safe mode with init file
mysqld_safe --init-file=/path/of/your/file

Stop and start the mysql server and you should be able to login!
:)

Saturday, December 13, 2014

Python - Dad Chinese Subtitles - Creating the correct chinese srt file

And so usually i will have some problems downloading movies for my dad.

My dad have strict criteria for those movies.
They must be high res ( 480p and above ) and MUST Have chinese subtitles as his "english" isnt that great....

And which movies usually has chinese subtitles?

Not a lot....

And so, there is a need for the english subtitles to be translated to chinese and "hopefully" be playable in his VLC.

But the translated "chinese" file converted using google translate is unable to play well... because there seems to be font error on the timecode... so... here is a "tested only once" script that seems to work...

=== CODE ===

#!/usr/bin/python
import sys

with open("english.srt") as f:
english_content = f.readlines()

with open("chinese.srt") as f:
chinese_content = f.readlines()

#print english_content[0]
#print english_content[1]
#print english_content[2]
#print chinese_content[2]

def keeporthrow(mystring):
try:
int(mystring[0])
return True
except ValueError:
return False

#print keeporthrow(english_content[1])
#print keeporthrow(english_content[2])

if (len(english_content) != len(chinese_content)):
print "English file: " + str(len(english_content))
print "Chinese file: " + str(len(chinese_content))
print "Rows count dont match!"
exit

for i in range(0,len(english_content)):
#for i in range(0,10):

if keeporthrow(english_content[i]):
print english_content[i].rstrip('\n')
else:
if len(chinese_content[i]) == 1:
sys.stdout.write("\r\n")
else:
print chinese_content[i].rstrip('\n')

=== CODE ===

Monday, December 01, 2014

Disable local delivery Linux

What I did to disable local delivery. I'll be using the example.com domain.
Requirements:
  • example.com A entry pointing to IP address assigned to one of the eth interfaces.
  • /etc/hosts defining example.com assigned to the very same IP address as above
  • example.com MX records pointing to Google servers (ASPMX.L.GOOGLE.COM, etc)
  • default sendmail installation (mine was on Ubuntu)
Steps:
vim /etc/mail/sendmail.mc
at the end:
define(`MAIL_HUB', `example.com.')dnl
define(`LOCAL_RELAY', `example.com.')dnl
and then:
sendmailconfig (or /etc/mail/make depending on your distro)
service sendmail restart
testing:
echo -e "To: user@example.com\nSubject: Test\nTest\n" | sendmail -bm -t -v
echo -e "To: user\nSubject: Test\nTest\n" | sendmail -bm -t -v
You should see it connecting to the google server and then you should see your mail being delivered to your Google inbox.

Copied from : http://serverfault.com/questions/65365/disable-local-delivery-in-sendmail

Sunday, November 09, 2014

Apple update time...

And so the iOS8.1 is now jailbreakable.

Upgrade your apple device to iOS8.1.
Download jailbreak stuff @ http://en.pangu.io/
Run as administrator.
Turn on airplane mode.
Jailbreak.
When it says there is no available storage, click ok.
Reboot...

Search for cydia.
Launch it to "re-adjust the disk space", will auto reboot.

Add to cydia the repo for AppSync.

http://apt.178.com
Install AppSync for iOS8 from the repo.

For "cracked" stuff...
Only Appcake seems to work for me.
Install appcake v4.83 via appcake repo at http://cydia.iphonecake.com
Reboot

For iLexRat just in case...
http://cydia.myrepospace.com/iLEXiNFO/

Wednesday, October 22, 2014

Mac OSX - Died - Time to reformat...

And so my MAC OSX decided not to boot up one fine day.

Luckily, i had my installer file. ( OSX Mavericks )
No DVD on hand, so thought i'll just pop OSX installer to thumbdrive.
Get a thumbdrive with at least 8GB.
Format it to Mac OS X Extended ( Journaled ). ( In this case called untitled )
Pop a terminal and sudo.
./YOURPATH/Install\ OS\ X.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /YOURPATH/Install\ OS\ X\ Mavericks.app --nointeraction

Wait a while, then it should be done.

Boot using thumbdrive.
But as i want to copy the files out, i've popped a terminal to copy the files to another hard disk....
But amazingly, the screen will go to sleep....
So, pop another terminal...
-> pmset -a sleep 0 displaysleep 0
Dont close the terminal, and your screen will stay on.... and on.... and on....

Sunday, September 14, 2014

Changing my TPLink Router to something more useful!

Well,

Since gotten my new fiber ( with the purchase of a new router ), i guess it's time to retire my old TP Link Router... But... Wait... What if i can make it be my downloader machine?

Lets go install openwrt!

And let's OPKG the following:
blkid - 2.21.2-1
block-mount - 0.2.0-9
kmod-fs-ext4 - 3.3.8-1
kmod-lib-crc16 - 3.3.8-1
kmod-scsi-core - 3.3.8-1
kmod-usb-storage - 3.3.8-1
libblkid - 2.21.2-1
libpcap - 1.1.1-2
libuuid - 2.21.2-1
swap-utils - 2.21.2-1
tcpdump - 4.2.1-3

Well, time to format my thumbdrive to ext4 and create a stupid script to fetch somewhere to download!

Wednesday, September 10, 2014

Pushing mysqldump to another server!

Server 1 need to mysqldump to server 2.
HOW HOW HOW!

mysqldump DBNAME tablename | ssh root@remoteserver.com "mysql -D dbname"

Best to use the authorized keys to ssh! So no need password lah!

SSH Login without password!

On server 1 
ssh-keygen -t rsa
Leave password blank

Generating public/private rsa key pair.
Enter file in which to save the key (/home/root/.ssh/id_rsa): 
Created directory '/home/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/root/.ssh/id_rsa.
Your public key has been saved in /home/root/.ssh/id_rsa.pub.
The key fingerprint is:
XXXXXXX

SSH to server 2 and make directory
ssh root@server2 mkdir -p .ssh

Cat your server 1 key to there
cat .ssh/id_rsa.pub | ssh root@server2 'cat >> .ssh/authorized_keys'

To test on server 1
ssh root@server2

Tuesday, July 29, 2014

Adding that damm trash can back to Kali Linux.

Click “Applications” on the toolbar, then hover on “System Tools” for a second then click on “dconf Editor.”
Expand > org> gnome > nautilus > desktop
Check and uncheck trash-icon-visible

Copied from:
http://lewiscomputerhowto.blogspot.sg/2013/09/how-to-add-trash-icon-to-kali-linuxs.html

Wednesday, July 09, 2014

IPAD Firmware Updates Files for iTunes Update.

Updated my iPad.

Downloaded the firmware via iclarified.

On Windows XP :
Documents and Settings\\Application Data\Apple Computer\iTunes\iPhone Software Updates
Users\\AppData\Roaming\Apple Computer\iTunes\iPhone Software Updates
~/Library/iTunes/iPhone Software Updates


On Windows Vista/Windows 7/8:

On Mac:

Paste files in above directory. 
Go iTunes > Update.
:)

External Link:
http://www.everymac.com/ultimate-mac-lookup/
http://www.iclarified.com/8500/where-to-download-ipad-firmware-files-from

Wednesday, June 18, 2014

Windows XP Dying... No more updates!!!!

Make your Windows XP = POS ( Point of Sale )
So you can update...

Notepad > Save as .reg > Double click
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\WPA\PosReady]
"Installed"=dword:00000001


Works???

Debian - MySQL - Why i cannot install?

GRRRRRRRRRrrrrrrrrr

Fired up a debian template.
Could not install a stupid mysql.
2014 already... WHY LIKE THAT?

apt-get install mysql-server
XXXXXXX

mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[Note] Plugin 'FEDERATED' is disabled.
/usr/libexec/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Compressed tables use zlib 1.2.3
InnoDB: Using Linux native AIO
InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: Completed initialization of buffer pool
InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

How u fix?
nano /etc/mysql/my.cnf
Add this -> innodb_use_native_aio=0 * This should be under the [mysqld] tag

Change your root password ( which is empty because some how something screw up...)
mysqladmin -u root password NEWPASSWORD

Then suei suei if you get an error as such:
'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)'

cat /etc/mysql/debian.cnf
Note the password in the client section.
[client]
host     = localhost
user     = debian-sys-maint
password = SOMERANDOMPASSWORDHERE
socket   = /var/run/mysqld/mysqld.sock

mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'SOMERANDOMPASSWORDHERE';

/etc/init.d/mysql restart
*pray

AB - Apache Benchmark?

ab -n 5000 -c 30 "somesite.com"

Wrong time again Mr Windows 2008?

Grrrrr....
One of my VM date time running windows 2008 is screwed again.
Used this to fix it once and for all...

Stop the W32Time service: 
net stop w32time

Configure the external time sources
w32tm /config /syncfromflags:manual /manualpeerlist:"0.pool.ntp.org, 1.pool.ntp.org, 2.pool.ntp.org"

Make your PDC a reliable time source for the clients. 
w32tm /config /reliable:yes

Start the w32time service: 
net start w32time

The windows time service should begin synchronizing the time. 
You can check the external NTP servers in the time configuration by typing: 
w32tm /query /configuration

Check the Event Viewer for any errors.

*Pray

Dealing with AWSTATS.

My friend passed me an apache log file and i've attempted to parse it to AWSTATS for more "report style" human readable format...

* history > should_be_the_steps_to_follow

Wget the file / Unzip the file
wget "http://prdownloads.sourceforge.net/awstats/awstats-7.3.zip"
unzip awstats-7.3.zip

Make a directory and move awstats there.
mkdir /usr/local/awstats/
mv * /usr/local/awstats/

cd tools/
perl awstats_configure.pl
*Follow instructions to add stuff to apache/default site.

mkdir /var/lib/awstats/ ( for temp file creation i guess )

============= Jobs Done ============= 

Creating a config file for awstats.
nano /etc/awstats/awstats.demo.conf ( Replace demo with a name for easy identification )
- Change your logfile path to point to the apache access log

Execute the awstats to read your log and do it's stuff.
perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=demo -update

To build static pages ( reports ) for your users.
perl /usr/local/awstats/tools/awstats_buildstaticpages.pl -config=demo -update -dir=/some/directory/here/

Monday, January 06, 2014

Cydia Sources - iOS7 Finally Jailbreakable!

Added the following to my cydia sources!

http://repo.appvv.com
http://cydia.iphonecake.com
http://repocydia.com/
http://sinfuliphonerepo.com/
http://cydia.xsellize.com

Old
http://repocydia.com
http://rpetri.ch/repo




Love Is...


Copied from : http://www.stewpig.com/others/around-you/love-is-16-pics/2014/01/03/