Wednesday, May 27, 2015

How to disable CTRL-ALT-DEL from rebooting a Linux system

The action taken for CTRL-ALT-DEL is defined in /etc/inittab and if we will look in that file we will see a line similar to the one from bellow (taken from a Debian system):
# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
Here is another example: on RedHat based systems this line will look like:
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
If we want to disable this action we only have to change this line. We can delete it, comment it, or even replace it with something like:
ca:12345:ctrlaltdel:/bin/echo "CTRL-ALT-DEL is disabled"
After making any changes to the inittab file, you will have to tell init to reload it, in order to activate the changes. To do that, simply run as root:
init q

Thursday, February 26, 2015

Logon failure: the user has not been granted the requested logon type for this computer.

1.       Is file sharing turned on?
2.       Have you turned off Password protection?
Try checking the Advanced Sharing Settings from Network and Sharing Center. To do this, follow these steps.
1.       Click Start, Control Panel and then Network and Sharing Center.
2.       Now click Change Advanced Sharing Settings.
3.       Now make sure File and Printer Sharing is Turned On and Password Protected Sharing is Turned Off.
If that does not resolve the problem, try to check the Group Policy Settings.
1.       Click Start and type gpedit.msc in the start search box and press Enter.
2.       Navigate to the following location
Computer Configuration/
Windows Settings/ Security Settings/ Local Policies
3.       Under this click on User Rights Assignment.
4.       Double click Access this computer from the network and check that EVERYONE is added to the list.
5.       If not add it by clicking Add User or group and then type EVERYONE, click OK and then Apply and OK.
Refer: http://windows.microsoft.com/en-US/windows7/Networking-home-computers-running-different-versions-of-Windows

Wednesday, February 25, 2015

Missing or No Security Tab Found in Windows XP Professional

Security tab for the properties of files or folders in Windows XP Professional is the important functionality that enable administrators and users to define security permissions and rights for particular user or group to the computer resources. By default, Windows XP Professional follows recommended setting to enable the use of simple file sharing that hide the Security tab, leaving you with only General, Sharing, Web Sharing & Customize tabs as in the Simple File Sharing UI.

So to see and unhide the Security tab, just use the following steps:
  1. Launch Windows Explorer or My Computer.
  2. Click on the Tools at the menu bar, then click on Folder Options.
  3. Click on View tab.
  4. In the Advanced Settings section at the bottom of the list, uncheck and unselect (clear the tick) on the “Use simple file sharing (Recommended)” check box.
  5. Click OK.
Security tab is available only to Administrator or users with administrative rights. So make sure you login as one. And security can only be set in an NTFS partition. If you’re still having problem to reveal or display the Security tab on files or folder properties, check out the following registry hack and set the value to 0 or simply delete the key:
Hive: HKEY_CURRENT_USER
Key: Software\Microsoft\windows\CurrentVersion\Policies\Explorer
Name: Nosecuritytab
Type: REG_DWORD
Value: 1
If you’re using a Windows XP Professional system that is installed in a Workgroup, the Security tab is also hidden by default because in Windows XP Home Edition and Windows XP Professional, guests are forced to log on to a workgroup. Follow the instruction and information on Microsoft Knowledge Base where you need to set the value for ForceGuest registry key.

Sunday, February 15, 2015

Remote access to Debian Printing (CUPS) web interface from LOCAL

The Common UNIX Printing System (or CUPS) is a printing system and general replacement for lpd and other older systems. The CUPS Debian packages forms a nice, powerful and relatively easy to use printing system on Debian. (http://www.cups.org/)

Install Software:

aptitude update
aptitude install cups cups-client

Start the software:

/etc/init.d/cups start

The easiest way is to use the cups web interface. You can see it by going to

http://localhost:631/admin

But to get to this page remotely for a server, you need to first make some edits to the cupsd.conf file. So do the following:

1. Edit the cups configuration file by first running the following command on your server:

sudo nano /etc/cups/cupsd.conf

2. Change this section :

# Only listen for connections from the local machine.
#Listen localhost:631
Port 631
Listen /var/run/cups/cups.sock

3. Then change this sections :

< Location / >
# Restrict access to the server...
Order allow,deny
Allow from@LOCAL
< /Location >
< Location /admin >
# Restrict access to the admin pages...
Order allow,deny
Allow from@LOCAL
< /Location >
< Location /admin/conf >
AuthType Default
Require user @SYSTEM
# Restrict access to the configuration files...
Order allow,deny
Allow from@LOCAL
< /Location >

4. Finally, restart cups with the following:

sudo /etc/init.d/cups restart

5. You should now be able to log into cups on your server with:

http://your_server_ip_address:631


Note that when you change something, it may tell you that you need to add a certificate to firefox. Do so by clicking the add/get certificate button at the bottom of the firefox error message page. It will also tell you that to change stuff, you need to use the "https" version of the page instead of "http" so just go to:

https://your_server_ip_address:631

You might also have to open/port forward tcp port 631.

Monday, October 13, 2014

Microsoft Excel Crack Sheet Protection Password


Microsoft Excel

Crack Sheet Protection Password

This routine provides a password to unprotect your worksheet. However, it may not give you the original password that was used.
Open the workbook that has the protected sheet in it. Hit Alt+F11 to view the Visual Basic Editor. Hit Insert-Module and paste this code into the right-hand code window:



Sub PasswordCracker()
  Dim i As Integer, j As Integer, k As Integer
  Dim l As Integer, m As Integer, n As Integer
  Dim i1 As Integer, i2 As Integer, i3 As Integer
  Dim i4 As Integer, i5 As Integer, i6 As Integer
  On Error Resume Next
  For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
  For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
  For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
  For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
    
       
 ActiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & _
      Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
      Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
  If ActiveSheet.ProtectContents = False Then
      MsgBox "One usable password is " & Chr(i) & Chr(j) & _
          Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
          Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
   ActiveWorkbook.Sheets(1).Select
   Range("a1").FormulaR1C1 = Chr(i) & Chr(j) & _
          Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
          Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
       Exit Sub
  End If
  Next: Next: Next: Next: Next: Next
  Next: Next: Next: Next: Next: Next

End Sub


Close the VB Editor window. Navigate to the worksheet you want to unprotect. Hit Tools-Macro-Macros and double-click PasswordCracker in the list.

Wednesday, September 24, 2014

How to set up a squid Proxy with basic Username and Password Authentication Using NCSA

You can configure Squid to prompt users for a username and password.
Squid comes with a program called ncsa_auth that reads any NCSA-compliant encrypted password file. You can use the htpasswd program that comes installed with apache2-utils to create your passwords. Here is how it's done:

1) Create the password file. The name of the password file should be /etc/squid/squid_passwd, and you need to make sure that it's universally readable.

[root@tmp]# touch /etc/squid/squid_passwd
[root@tmp]# chmod o+r /etc/squid/squid_passwd

2) Use the htpasswd program to add users to the password file. You can add users at anytime without having to restart Squid. In this case, you add a username called www:

[root@tmp]# htpasswd /etc/squid/squid_passwd www
New password:
Re-type new password:
Adding password for user www
[root@tmp]#

3) Find your ncsa_auth file using the locate command.

[root@tmp]# locate ncsa_auth
/usr/lib/squid/ncsa_auth
[root@tmp]#

4) Edit squid.conf; specifically, you need to define the authentication program in squid.conf, which is in this case ncsa_auth. Next, create an ACL named ncsa_users with the REQUIRED keyword that forces Squid to use the NCSA auth_param method you defined previously. Finally, create an http_access entry that allows traffic that matches the ncsa_users ACL entry. Here's a simple user authentication example; the order of the statements is important:

#
# Add this to the auth_param section of squid.conf
#
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwd

#
# Add this to the bottom of the ACL section of squid.conf
#
acl ncsa_users proxy_auth REQUIRED

#
# Add this at the top of the http_access section of squid.conf
#
http_access allow ncsa_users

5) This requires password authentication and allows access only during business hours. Once again, the order of the statements is important:

#
# Add this to the auth_param section of squid.conf
#
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwd

#
# Add this to the bottom of the ACL section of squid.conf
#
acl ncsa_users proxy_auth REQUIRED
acl business_hours time M T W H F 9:00-17:00

#
# Add this at the top of the http_access section of squid.conf
#
http_access allow ncsa_users business_hours

Remember to restart Squid for the changes to take effect.

Tuesday, September 23, 2014

Adobe acrobat pro 8.0/8.1 activated, re-activated

 Adobe Acrobat pro 8.0/8.1 RI count number solution to the problem can not be activated

If you have installed Adobe Acrobat Professional 8 can not be activated, or resume the installation, Adobe Acrobat Professional 8 need to re-activate, and different methods of activation activation method when first installed, after several tests can be re-activated:

Method One
  1.  delete files
    C: \ Documents and Settings \ All Users \ Application Data \ FLEXnet \ adobe_00080000_tsf.data
  2.  start Adobe Acrobat 8, wait for a while to re-activate the interface;
  3.  Click "Other activation options"
  4.  select "activate by phone" and press "OK"
  5.  running Adobe Acrobat 8 ??RI, copy the activation code to RI to obtain an authorization code, press the "Activate"
  6.  enter a new license key, press the "activate"

Method Two
  1.  delete files
    C: \ Documents and Settings \ All Users \ Application Data \ FLEXnet \ adobe_00080000_tsf.data
  2.  click Change serial number "
  3.  running Adobe Acrobat 8 ??RI, press the "Generate Serial" Get the serial number, enter the first line of the serial number and press the "Activate"
  4.  select "Adobe Acrobat 6 Standard, the second line of the input RI serial number and press" Next "
  5.  select the telephone activation "
  6.  Copy the activation code to RI to obtain an authorization code, press the "Activate"
  7.  Enter the new license key, press the "activation"

Adobe Acrobat 8.1 Professional software enables business professionals to reliably create, combine, and control Adobe PDF documents for easy,:)

Thursday, March 6, 2014

How to combine MP4 files on the Debian linux

How to combine MP4 files on the Debian linux

If you are looking to combine MP4 files from the command line here is the easiest solution.  First you need to use the following command to install the program.

sudo apt-get install gpac

Once installed you will be able to run the following command to join the files.

MP4Box -cat mp4_file_part_1.mp4 -cat mp4_file_part_2.mp4 -new joined_file.mp4

You should now be able to combine MP4 files from the command line, and pretty quick at that.

Wednesday, February 12, 2014

Iptables String Matching for Advanced Firewalling

Introduction.

When it comes to any server or network connected to the internet, security from malicious files and hack attempts is a matter of concern for any administrator. Linux provides its own firewall from the early releases itself. The current iptables firewall maintained by the netfilter team is advancing to more powerful security and network management tool with the recent releases.It will be a topic of interest for any linux based server/network administrator. This article covers effective configuration and optimization of the iptables firewall system in 2.6.x kernels in order to more effectively defend against TCP attacks and to drop unwanted packets without messing them up with your business critical services!!

Kernels from 2.6 include support for matching strings present in IP packets, inspecting the entire packet data. Earlier kernels supported matching at the IP header level only, which was a limitation as the rules can be formed only based on header values like IP addresses, ports, packet state etc. The netfilter iptables firewall system has undergone great advancements in the latest kernels, with the modified string matching option being more interesting among them for server administrators. The rules, based on string matching functions, are very easy to implement. This guide intends to introduce the method to users with a basic understanding of networking and iptables.

System Requirements.

  1. Preferred kernel version : 2.6.18 or later.
  2. The iptables program(1.3.5 or later) installed on your machine.
  3. The kernel should be compiled with string matching support. To do this, the following line should be added to the .config file prior to compiling the kernel:
    CONFIG_NETFILTER_XT_MATCH_STRING=m
    

If you use a pre-complied kernel, check for this option in the config file with the appropriate version of the kernel in your /boot directory. If present, it means that netfilter string matching is compiled as a module. Make sure that the module is loaded (using the lsmod command or by looking for the appropriate entry in the /proc/modules file). The minimum requirement is a 2.6.14 kernel, however it is a bit difficult to get it working on kernels before 2.6.18. Customising the kernel and iptables is required in that case. Suggested configuration options for older kernels can be detailed in another article, if there is demand.

Formating the Rules.

If iptables is installed with string matching support, its man page can be found with the following command:

iptables -m string -help
Here is the relevant section from the iptables(8) man page:

   string

         This  modules  matches  a  given string by using some
pattern matching strategy. It requires a linux kernel >= 2.6.14.

        --algo  bm|kmp

              Select the pattern matching strategy. (bm = Boyer-
Moore, kmp = Knuth-Pratt-Morris)


        --from offset

              Set the offset from which it starts looking for any
matching. If not passed, default is 0.

        --to offset

              Set the offset to which it starts looking for any
matching. If not passed, default  is  the

              packet size.

        --string pattern

              Matches the given pattern.  --hex-string pattern
Matches the given pattern in hex notation.


In iptables 1.3.5, you need to specify the algorithm to use for string matching using the --algo option. We may limit the search by specifying the offset values as well. Two algorithms can be used, Boyer-Moore and Knuth-Morris-Pratt. More information regarding these algorithms can be found at Wikipedia - for Boyer-Moore the URL is:

http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm

and for Knuth-Morris-Pratt the URL is:

http://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm

Boyer-Moore is efficient and fast and is preferable in most cases.

Common Applications and Useful Example Rules:

1) To prevent an intrusion attempt.

In case, a suspecious URL upload using the webserver was detected, You could frame similar rules as follows.
iptables -I INPUT 1 -p tcp --dport 80 -m string --string "cmd.exe" --algo bm -j DROP
The rule blocks all packets to port 80 containing the string cmd.exe. Mod_security is an option for the same, but it can be an overload to your busy webservers.

2) To defend DDOS to a service.

It is a common case where we need to drop requests to a domain when it is under DDOS. mod_dosevasive is an option, but it really overloads the webserver. String matching option can be utilized here without overloading the webserver.

iptables -I INPUT 1 -p tcp --dport 80 -m string --string "domain.com" --algo kmp -j DROP
The rule, blocks all web requests to domain.com. These rules can also be used in conjunction with other iptables matches and options depending on what is required.

3) To Defend against E-mail Spoofing.

We can make use of the string matching option in numerous cases to drop intruder and spam packets before they enter the server. Another instance for example is, if the mail server is receiving many spoofed e-mails with a common 'Subject'.If the spammer is using a unique IP address, it is very easy to block him using RBLs, conventional iptables rules etc. But when the spammer is using different IP addresses, it makes things difficult for the administrator.In such a case, the following string based rule can be added to the firewall so that the mail server will not get overloaded by the spoofed mails.
iptables -I INPUT -p tcp --dport 25 -m string --string "Subject" --algo bm -j DROP

**Do it now with an optimised rule!

The same rule might be modified to one with less overhead (that is, it uses less resources) by limiting the search specifying offset values, and by assuming that the SMTP subject header will be within an offset limit of 15000 in the packet.
iptables -I INPUT -p tcp --dport 25 -m string --string "Subject"  --algo bm --to 15000 -j DROP

4) Other general cases.

Apart from the instances discussed above, you can make use of the string matching options, wherever you need to manage the packets entering a server or network,based on strings like URLs, file names, file contents etc.

Conclusion.

The string matching option can be effectively utilized when a network needs to be filtered using strings. We can block the packets right at the kernel level itself without overloading your server applications. However, there is a higher overhead involved for the kernel with string matching, compared to other ordinary iptables matchings. Offset limits should be specified for searching wherever possible in order to reduce this overhead.

Tuesday, September 10, 2013

Multiple IP addresses on One Interface

Multiple IP addresses on One Interface

Interface aliasing allows one interface to have multiple IP addresses. This is useful when more than one server is to be visible via the Internet. Note that virtual hosts can support multiple Apache servers with a single IP address. Apache responds to the domain name supplied by the client in the HTTP header. In many other situations, one external IP is needed for each server using a port.
This /etc/network/interfaces text assigns three IP addresses to eth0. 
 
 
auto eth0
allow-hotplug eth0
iface eth0 inet static
    address 192.168.1.42
    netmask 255.255.255.0
    gateway 192.168.1.1

auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
    address 192.168.1.43
    netmask 255.255.255.0

auto eth0:1
allow-hotplug eth0:1
iface eth0:1 inet static
    address 192.168.1.44
    netmask 255.255.255.0
 
 
An alias interface should not have "gateway" or "dns-nameservers"; dynamic IP assignment is permissible.
The above configuration is the previous traditional method that reflects the traditional use of ifconfig to configure network devices. ifconfig has introduced the concept of aliased or virtual interfaces. Those types of virtual interfaces have names of the form interface:integer and ifconfig treats them very similarly to real interfaces.
Nowadays ifupdown uses ip utility from the iproute2 package instead of ifconfig. The newer ip utility does not use the same concept of aliases or virtual interfaces. However, it supports assigning arbitrary names to the interfaces (they're called labels). ifupdown uses this feature to support aliased interfaces while using ip.
Also, ifupdown supports specifying multiple interfaces by repeating iface sections with the same interface name. The key difference from the method described above is that all such sections are treated by ifupdown as just one interface, so user can't add or remove them individually. However, up/down commands, as well as scripts, are called for every section as it used to be.
This /etc/network/interfaces text assigns three IP addresses to eth0.
 
 
auto eth0
allow-hotplug eth0
iface eth0 inet static
    address 192.168.1.42
    netmask 255.255.255.0
    gateway 192.168.1.1

iface eth0 inet static
    address 192.168.1.43
    netmask 255.255.255.0

iface eth0 inet static
    address 192.168.1.44
    netmask 255.255.255.0

# adding IP addresses from different subnets is also possible
iface eth0 inet static
    address 10.10.10.14
    netmask 255.255.255.0


Additional information can be found on the http://www.shorewall.net/Shorewall_and_Aliased_Interfaces.html page.

Thursday, July 25, 2013

How To Configure Wireless / WiFi Networking in Ubuntu via the Command Line (CLI)

How To Configure Wireless / WiFi Networking in Ubuntu via the Command Line (CLI)

There are a number of tutorials available on-line for sorting out WiFi in Ubuntu via the CLI, but most of them seem quite outdated, so I decided to do my own.

I did this on a minimal install of Ubuntu Lucid, so it is as up-to-date as possible. The PC I was using has no Windows Manager of Graphical Display Manager, just the good old terminal so all this is done via the CLI only. I did this using a USB WiFI dongle, but it should be the same whether you use an internal card or a USB card.

First, you need to install the relevant software. You need to have a wired connection at this point, otherwise this wont work.

sudo apt-get install wireless-tools wpasupplicant

If you are connecting to an open network, you wont need wpasupplicant. Next, you need to “bring up” (essentially this means activate) your WiFi interface. So, issue:

sudo ifconfig wlan0 up

Next, to make sure your wireless device is working as it should issue:

iwconfig

and then

sudo iwlist scan

This should show you some wireless networks as proof that the WiFi device is working, if something goes wrong here, then there is a problem with your device or driver and you need to get googling.
If you are accessing a secured network and you really should be, you need to access the correct version of your WiFi key. To get your key, issue this command:

wpa_passphrase YOURSSID YOURWIFIPASSWORD 

This will result in something that looks like this:

network={
ssid="YOURSSID"
#psk="YOURWIFIPASSWORD"
psk=fe727aa8b64ac9b3f54c72432da14faed933ea511ecab1 5bbc6c52e7522f709a


You need to make a note of the long phrase after psk= (NOT #psk=) as this your WiFi password in hex format.
Next, you need to edit your interfaces file, so issue:

sudo nano /etc/network/interfaces

At the end of this file, you need to add your WiFi configuration. Here are the options you can add.

auto wlan0     #change this to the name of your WiFi interface
iface wlan0 inet dhcp     #this is normally fine, if you want a static IP address replace “dhcp” with “static”
netmask 255.255.255.0     #change this as appropriate for your network, this value is usually right
gateway 192.168.1.1     #change this as appropriate for your network
address 192.168.1.100     #only needed for a static IP address
dns-nameservers 192.168.1.1     #only needed for a static IP address
wpa-driver wext     #you shouldn’t need to change this
wpa-ssid YOURSSID     #just type the name of your SSID here
wpa-ap-scan 1     #if the name of your SSID is hidden usually, type 2 instead of 1
wpa-proto WPA    #if you use WPA1 type WPA, if you use WPA2 type RSN
wpa-pairwise CCMP     #if you use AES type CCMP, if you use TKIP type TKIP
wpa-group CCMP     #if you use AES type CCMP, if you use TKIP type TKIP
wpa-key-mgmt WPA-PSK     #usually WPA-PSK (if you share a key) but sometimes WPA-EAP (for enterprises)
wpa-psk YOURHEXKEYFROMABOVE     #the hex key that you generated earlier

Thus, since I am using a WiFi card that is identified as wlan0 and am connecting to a WPA1 AES encrypted network called MYPLACE that isn’t hidden without a static IP address, this is what I added:

auto wlan0
iface wlan0 inet dhcp
netmask 255.255.255.0
gateway 192.168.1.1
wpa-driver wext
wpa-ssid MYPLACE
wpa-ap-scan 1
wpa-proto WPA
wpa-pairwise CCMP
wpa-group CCMP
wpa-key-mgmt WPA-PSK
wpa-psk 71c81a844973ae7bb1243141e5caa7b6bb0e2d7eetcetcetc


Finally, comment out the top section so it looks like this:

#auto eth0
#iface eth0 inet dhcp


This stops your wired network from working. This helps to ensure there are no conflicts. Remember, if you want your wired network to work again, remove these two comments (the #).
Finally, save the file by pressing CTRL and X and then pressing Y to save to the file. Now, reboot and your network should come up. Yay!
Some people have found that this doesn’t always work, so the next thing to do is to edit the configuration file for the wpasupplicant program. Do this by issuing:

sudo nano /etc/wpa_supplicant.conf

Basically, you add pretty much the same information here as you did to the interfaces file, except without the wpa- part. So, my file looks like this:

ap_scan=1
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="MYPLACE"
scan_ssid=0
psk=71c81a844973ae7bb1243141e5caa7b6bb0e2d7eetcetcetc
key_mgmt=WPA-PSK
proto=WPA
pairwise=CCMP
group=CCMP
}


As far as I am aware, the options are the same. So, edit this file as necessary, make sure you add the ctrl_interface and network={ at the beginning and the } part at the end. Save it and try restarting again. If it still doesn’t work, then kick your PC, wish you had installed Windows 7 instead and go off and do some Googling. You’ll find the answer on the Ubuntu forums and you’ll be happy again.

Best of luck!

Wednesday, July 10, 2013

Setup PPTP Server on Ubuntu 12.4 Server.

This guide has been tested with Ubuntu 12.4 Server.

Setup PPTP Server

First we need to install pptp server using apt-get 
 
# sudo apt-get install pptpd

Then we need to configure the pptpd.
 
# sudo nano /etc/pptpd.conf

Add server IP and client IP at the end of the file. You can add like below:
 
localip 192.168.0.1
remoteip 192.168.0.100-200

This sets up the PPTP server to use IP 192.168.0.1 while distributing the IP range 192.168.0.100 to 192.168.0.200 to PPTP clients. Change these as you wish as long as they are private IP addresses and do not conflict with IP addresses already used by your server.

Configure DNS servers to use when clients connect to this PPTP server
 
# sudo nano /etc/ppp/pptpd-options

Uncomment the ms-dns and add google like below or OpenDNS
 
ms-dns 8.8.8.8
ms-dns 8.8.4.4

Now add a VPN user in /etc/ppp/chap-secrets file.
 
# sudo nano /etc/ppp/chap-secrets

The column is username. Second column is server name, you can put “pptpd” in there. Third column is password. The last column is the IP addresses, you can put * to allow all IP.
 
# client        server  secret                  IP addresses
username * myPassword *

Finally start your server
 
# /etc/init.d/pptpd restart

Setup IP Forwarding

To enable IPv4 forward. Change /etc/sysctl.conf file, add forward rule blew.


 
# sudo nano /etc/sysctl.conf

Uncomnent the line
 
net.ipv4.ip_forward=1

Then reload the configuration
 
sudo sysctl -p

Add forward rule in iptables
 
# sudo nano /etc/rc.local

adding to the bottom just before the exit 0
 
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
iptables -A FORWARD -p tcp --syn -s 192.168.0.0/24 -j TCPMSS --set-mss 1356

This example is using 192.168.0 for its PPTP subnet. The second rule adjusts the MTU size :
You are done. Just reboot your server and you should be able to connect to using PPTPD and send all your traffic through this server.

Wednesday, January 9, 2013

Rip, copy a CD/DVD to ISO format.

Rip a CD/DVD to ISO format.

$ dd if=/dev/cdrom of=~/cdrom_image.iso

Rip a CD/DVD to ISO format.
An easy method to generate ISOs from CD/DVD media.

Alternatives

There are 2 alternatives

$ readom dev=/dev/scd0 f=/path/to/image.iso

Create a CD/DVD ISO image from disk.
Many like to use 'dd' for creating CD/DVD iso images. This is bad. Very bad. The reason this is, is 'dd' doesn't have any built-in error checking. So, you don't know if you got all the bits or not. As such, it is not the right tool for the job. Instead, 'reaom' (read optical media) from the wodim package is what you should be using. It has built-in error checking. Similarly, if you want to burn your newly creating ISO, stay away from 'dd', and use:

wodim -v -eject /path/to/image.iso
$ readcd dev= f=foo.iso

The only problem here is that there is no error checking or correction. The cdrecord package includes a command line tool called readcd that rips CDs to iso files quite nicely
 

Friday, August 24, 2012

Batch Encoding H.264 Video with HandBrake

Batch Encoding H.264 Video with HandBrake

(Just as in the previous section, in this section I’m going to use “H.264 video” as a shorthand for “H.264 baseline profile video and AAC low-complexity profile audio in an MPEG-4 container.” This is the combination of codecs+container that works natively in Safari, in Adobe Flash, on the iPhone, and on Google Android devices.)
HandBrake also comes in a command-line edition. As with ffmpeg2theora, the command-line edition of HandBrake offers a dizzying array of options. (Type HandBrakeCLI --help to read about them.) I’ll focus on just a few:
  • --preset "X", where “X” is the name of a HandBrake preset. The preset you want for H.264 web video is called “iPhone & iPod Touch”, and it’s important to put the entire name in quotes.
  • --width W, where “W” is the width of your encoded video. HandBrake will automatically adjust the height to maintain the original video’s proportions.
  • --vb Q, where “Q” is the average bitrate (measured in kilobits per second).
  • --two-pass, which enables 2-pass encoding.
  • --turbo, which enables turbo first pass during 2-pass encoding.
  • --input F, where “F” is the filename of your source video.
  • --output E, where “E” is the destination filename for your encoded video.
Here is an example of calling HandBrake on the command line, with command line flags that match the settings we chose with the graphical version of HandBrake.
you@localhost$ HandBrakeCLI --preset "iPhone & iPod Touch"
                            --width 320
                            --vb 600
                            --two-pass
                            --turbo
                            --input pr6.dv
                            --output pr6.mp4
From top to bottom, this command runs HandBrake with the “iPhone & iPod Touch” preset, resizes the video to 320×240, sets the average bitrate to 600 kbps, enables two-pass encoding with a turbo first pass, reads the file pr6.dv, and encodes it as pr6.mp4. Whew!

Tuesday, August 14, 2012

How to I change my Keyboard Layout on Openbox?

From a terminal run the following command:

sudo dpkg-reconfigure console-setup
 
This will step through various configuration options for your console, along with Keyboard Layout.

For temporarily switching between keyboard layouts

Especially if you don't have too many keybindings 
So I needed to have both the regular US keyboard as well as the US International keyboard so that I could type in Thai keyboard.
Here are the steps I took:
1) Determine which keyboard layouts you want to switch between. Determine if you want 2, 3, or more. This tutorial will work with as many as you need, but this is the first step 
2) Open up a text editor and open the file ~/.config/openbox/rc.xml
3) Scroll down to the keybindings section - you should see stuff like <keybinding key="“blah-blah”"></keybinding>
4) Find any line which says </keybinding>
5) Go to the end of that line and hit Enter
6) Copy and paste the following text:

    <keybind key="C-F11">
    <action name="Execute">
    <startupnotify>
    <enabled>true</enabled>
    <name>English keyboard</name>
    </startupnotify>
    <command>setxkbmap us</command>
    </action>
    </keybind>

    <keybind key="C-F12">
    <action name="Execute">
    <startupnotify>
    <enabled>true</enabled>
    <name>Thai keyboard</name>
    </startupnotify>
    <command>setxkbmap th</command>
    </action>
    </keybind>

7) Edit the <key=“C-F12”> and the <command>setxkbmap th</command> to fit your desires (C is Ctrl key, A is Alt key, S is Shift key, and change it if you want :-D)
8) Rinse, Lather, and Repeat for all of your other desired keymaps.
9) Restart Openbox or reboot computer.
That's it!

Sunday, July 22, 2012

How-to: Mount a Network drive in Ubuntu

Recently, one of my roommates bought an external network drive, so everyone in the house can upload their music and movies. It’s hooked right into the network through the router so it’s easy for anyone to access– pretty cool stuff. It was pretty simple to setup in Windows, but it took a little bit of research for Ubuntu. Specifically, we have Maxtor “Shared Storage II” hard-drive, and I wanted it to auto-mount each time I reboot my computer. I figured it out using the tutorial here, but the basics are below.
  1. First you will need to install the “smbfs” package. This is what we will use to mount the drive.
    sudo aptitude install smbfs
  2. We will also need a folder to mount the drive in. I used /media/public.
    sudo mkdir /media/public
  3. Then, we need to edit /etc/fstab. This is where we add all the information needed to find and mount the drive. Open /etc/fstab using the command:
    gksudo gedit /etc/fstab
    At the end of the file add the following lines:
    # Mount our network drive
    //SERVER/SHARE /MOUNT-POINT smbfs guest 0 0
    Where “SERVER” is the name of your drive on the network. This can be either a name or IP address. For example, mine was “MAXTOR”. Replace “SHARE” with the folder in the drive you’d like to mount– mine was “Public”. “MOUNT-POINT” is the directory we created earlier, such as “/media/public”. The rest of the parameters have to do with permissions, and also where you can add advanced options. For more information on the advanced preferences, see
    man mount.smbfs
  4. The final step is to tell the system to reload /etc/fstab and mount our drive. Do this with the command:
    sudo mount -a
    Then, you’re done! At this point you should be able to see the files in your drive with the command
    ls /MOUNT-POINT

Thursday, June 14, 2012

How to join or merge multiple .avi or .mpg files

I have recently started watching the fab serialized movie Bloodspell, which is created entirely in Neverwinter Nights.
Bloodspell is released in a series of 6-7 MB files. So far they’re up to part 7. This certainly makes it easier to download on to my laptop and enjoy 10 minutes of Bloodspell at a time. However, I want to burn this to a DVD and watch all seven at once on my home DVD player. Before I did this I just wanted to string together the 7 .avi files into one larger file. (I can’t stand a mess!) Sounds like a simple request? Guess what, in my distro, Ubuntu, it is!

This will most likely work on just about any linux distro that includes the ability to install mplayer/mencoder.
First, let’s get the right programs.
sudo apt-get install mencoder mplayer
Now that the hard part is out of the way, we’re going to make use of the wonderful cat command. I’d renamed each Bloodspell video as b1.avi – b7.avi. Now to string them all end to end.
cat b1.avi b2.avi b3.avi b4.avi b5.avi b6.avi b7.avi > bloodspell.avi
Now we’re 2/3 of the way there! Stringing together .avi files can cause a breakdown in the sync between video and sound. So, we’ll use mencoder to sort things out.
mencoder -forceidx -oac copy -ovc copy bloodspell.avi.avi -o bloodspell_final.avi
That’s it! You’ve got one contiguous .avi file now containing all seven bloodspell releases to date. This will of course work with other .avi files. It will also work with .mpg or .mpeg files as well.
Later we’ll discuss getting this .avi file on to a DVD so you can watch it anywhere.
geek out.

Wednesday, May 9, 2012

Convert a video to black and white on Ubuntu

Convert a video to black and white on Ubuntu 


First: Install MPlayer 
sudo apt-get install mplayer libxine-extracodecs

If you can not install libxine-extracodecs, skip it. 

Then: Convert your video 
mencoder color-video.avi -o black-white-video.avi -vf hue=0:0 -oac copy -ovc lavc
or 
mencoder color-video.avi -o black-white-video.avi -vf hue=0:0 -oac pcm -ovc lavc

Good luck:)

Tuesday, September 6, 2011

How to increase internet speed in ubuntu

Internet speeds in Ubuntu can be increased. Simply follow the steps.

* Open a Terminal via Applications->Accessories->Terminal and type the following


sudo vim /etc/sysctl.conf (press i for edit mode)


* Then Paste the Following at the end of the file:


## increase TCP max buffer size setable using setsockopt()

net.core.rmem_max = 16777216

net.core.wmem_max = 16777216

## increase Linux autotuning TCP buffer limits

## min, default, and max number of bytes to use

## set max to at least 4MB, or higher if you use very high BDP paths

net.ipv4.tcp_rmem = 4096 87380 16777216

net.ipv4.tcp_wmem = 4096 65536 16777216

## don't cache ssthresh from previous connection

net.ipv4.tcp_no_metrics_save = 1

net.ipv4.tcp_moderate_rcvbuf = 1

## recommended to increase this for 1000 BT or higher

net.core.netdev_max_backlog = 2500

## for 10 GigE, use this, uncomment below

## net.core.netdev_max_backlog = 30000

## Turn off timestamps if you're on a gigabit or very busy network

## Having it off is one less thing the IP stack needs to work on

## net.ipv4.tcp_timestamps = 0

## disable tcp selective acknowledgements.

net.ipv4.tcp_sack = 0

##enable window scaling

net.ipv4.tcp_window_scaling = 1



* Then type the follwing to exit and save what you have just done. Press ESC to quit the edit mode and type the following.


:wq


* Then type the following to to apply the settings.


sudo sysctl -p


* You can disable all these settings by removing these lines you added via:


sudo gedit /etc/sysctl.conf

Tuesday, August 16, 2011

HOW TO : Convert .flv to .mp3 in Ubuntu, Debian Linux

Converting flv to mp3 has become so easy in Linux within few minutes.

Installation of FFmpeg on Debian OR Ubuntu Linux

* root:~#apt-get install ffmpeg

Converting .flv to .mp3

* ffmpeg -i input_filename.flv -acodec copy output_filename.mp3

Good luck :)