Tuesday, November 19, 2013

Changing your vnc password

Your VNC password is not the same as your UNIX password. Your VNC password must be set yourself. Your VNC password is encrypted within the passwd file in your .vnc directory. You can try to decrypt it (not recommended), or you can replace it (recommended).

Your VNC password and Unix logon password are two separate entities, so it's wise to choose a VNC password that is different than your Unix password. You can use the pwhelp command on Unix to generate a secure password for the VNC server.

To change the VNC password you must first delete the existing password file. From your home directory on Unix use the rm .vnc/passwd command to do this. Once you've accomplished that all you need to do is restart your Unix VNC session (use vncserver). The VNC server will recognize that you don't have a password set and prompt you for a new password. This enables you to keep an existing session active without having to restart the VNC server.

hostname% rm .vnc/passwd
remove .vnc/passwd? y
hostname% vncserver
You will require a password to access your desktops.

Password: ********
Verify: ******** 

Sunday, November 10, 2013

Calculating Networks, Hosts and Broadcast Addresses

134.77.168.143 / 27

134.77.168.143
255.255.255.224

Binary 
134     .   77   .   168  .   143
10000110.01001101.10101000.10001111
255    .    255    .   255   .   224
11111111.11111111.11111111.11100000

Like Bits = Network
10000110.01001101.10101000.100 00000  /27
134     .   77   .   168  .  128
Broadcast = All Bits on
10000110.01001101.1010100.100 11111  /27
134     .   77    .  168 .   159

First Usable = First Bit on
10000110.01001101.1010100.100 00001  /27
134     .   77   .   168  .  129
Last Usable
10000110.01001101.1010100.100 11110  /27
134     .   77   .   168 .     158

.128 64 32 16 8 4 2  1
.X     X  X  X X X X X

Wednesday, October 23, 2013

Mail Tsunami

A tempestuous email thread, visualized to be unscathed but resulting in a useless loss of  resources. It's not like that I have never seen such email threads. A long time ago at some point, I also used to be a part of these chains. But nevertheless, this thread was really different involving thousands of people and was really tempting for each one to revert. It was tantalizing for me too but I preferred to be on shore.

Last week an email was sent which was intended only for a small set of managers to encourage their staffs to complete an online training by the end of the month. But, in a move reminiscent of other email storms*, the unnamed sender mistakenly included a "xyz_training" mailing list that contained the addresses of thousands of employees – presumably without a restricted senders' list.

Now while the managers were discussing if the training was relevant to their staff (keeping the mailing list in the 'To:' line), someone triggered the storm by asking to be removed from the mailing list. It gathered momentum, mainly from the Indian offices, with lots of 'unsubscribe' and 'me-too' requests, ultimately nettled by enormous vague mails popping up the inbox,most of the employees requested not to "reply all" ,although they themselves were helping the thread to proliferate.It ended up in a complete plethora of chain mails.

Just when it looked like the storm had ended, it quickly picked up the pace again as employees in the US opened their mails in the morning.

Now I made some calculation in this mayhem.
Lets assume there are approximately 35,000 people on that thread.
A rough approximation of 270 minimum new Useless emails in my inbox that day.
i.e. 35,000 x 270 ~= 9.5 million emails worth of traffic.
Going by a conservative 50 KB per email.
That’s 475 GB worth of junk on the server.
Going by the past trend(from when this last happened), that’s translates to > $600,000 for the company.

The easy way to avoid these storms is to just ignore those mails that you don’t find relevant instead of hitting the "Reply-All" button or if you find it to be too much intractable, then choose the "Ignore" button and you will not be getting any mails further from that source.
Take precautions while broadcasting a mail to a large audience, keep the group-mailer-id in Bcc field and in the end of mail body mention the Bcc:group-mailed-id to let people know which audience is being targeted.

Sunday, September 29, 2013

for-else loop in python

This is a very interesting constructor in python and I m quite impressed with this. A very intelligent way to combine a loop with a condition.

Example 1:
foo = [ 1, 2, 3 ]
for i in foo:
    print "inside for loop with value %d"  %(i)
else:
   print "inside else condition %d" %(i)

Output:
inside for loop with value 1
inside for loop with value 2
inside for loop with value 3
inside else condition 3

Example 2:
foo = [ 1, 2, 3 ]
for i in foo:
     if i = = 2:
           print "inside for loop with value %d"  %(i)
           break
else:
   print "inside else condition %d" %(i)

Output:
inside for loop with value 2

Example 3:
foo = [ 1, 2, 3 ]
for i in foo:
     if i = = 2:
           print "inside for loop with value %d"  %(i)
           continue
else:
   print "inside else condition %d" %(i)

Output:
inside for loop with value 2
inside else condition 3

Example 4:
foo = [ 1, 2, 3 ]
for i in foo:
     if i = = 3:
           print "inside for loop with value %d"  %(i)
           break
else:
   print "inside else condition %d" %(i)

Output:
inside for loop with value 3


for-else loop basically means "find some item in the iterable, else if none is found then look into else". In simple words, we can say when for loop gets fully exhausted(i.e; even after looking through all the iterables, if we don't find any item that can make us stop in those iterable item/s) then we should look into else condition. See Example 1 and 3.

If we find a condition in for loop, that can interrupt the for loop and terminate it earlier than it is supposed, then that means we have found something in for loop iterables that we were looking for(see Example 2 and 4), so there is no need to check into else condition.

Update (Dec 21, 2017): I guess I could simply summarize the for-ELSE loop as for-NoBreak loop. I mean when no BREAK is encounter in for loop, then only ELSE condition gets executed.

Update (Oct 12, 2020): Food for thoughts:
arr = [1, 2, 3, 4]
Question 1:
def f():
    for i in arr:
        if i == 4:
            break
        print(i, end=' ')
    else:
        print("else part")
Output: 1 2 3

Question 2:
def f():
    for i  in arr:
        pass
    else:
        print("else part")
Output: else

Saturday, February 16, 2013

Windows 7’s Secret GodMade Power

Well, it’s not really a mode. To be clear, it’s not quite as magical or all-powerful as the name implies. It only organizes administrators work more efficiently by dumping all the controls in one central location for easy access. But I find it quite useful from time to time.
  • Create a new folder anywhere (I set mine up on desktop)
  • Rename the folder and paste in the following text: GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}
Once that is done, the folder's icon will change to resemble a control panel and will contain all the control options. 

You can also choose to sell your system’s soul to the devil. “GodMode” is just a prefix and you can choose any word you like. For ex:  DevilMode.{ED7BA470-8E54-465E-825C-99712043E01C}


Saturday, January 19, 2013

Protect your privacy in internet

Every time you connect to a website it simply scans the source IP address and hence your identity is exposed. You never know when your internet activity is no more private for you. When you surf the internet, Internet Protocol address is exposed. This might be used by hackers to gain access to your computer and all your personal information.

Being anonymous on the internet can benefit you in many ways. Few of them can be enlisted as:
1. Hiding your IP address helps you to protect your privacy from any kind of fraud.
2. You can also access the websites which previously you were banned from surfing using your Proxy IP address.
3. You can also protect your computer from spyware by hiding your IP address.
4. Hiding your IP address also protects your system from the constant display of popup ads.
5. The main benefits of hiding your IP address are to protect your system from others monitoring your system.

Changing your IP address is simply the basic way to hide your presence on the internet. If you can use and show a fake IP address, then you have now successfully protected your privacy and have become anonymous on the internet as shown in below figure.



This can be done in many ways:

1. Using Proxy sites to change your IP: There have been a lot of sites that allow you to browse anonymously. All you need is a web browser and a working internet connection. http://newipnow.com/ is such a website from where you can access any website with different IPs.

2. Using Proxy/Socks and Proxy tunneling applications: This method is a bit more technical than the previously mentioned. It requires the usage of proxies or IPs that you want to use. There are also different kinds of proxy, and a better one noted is the kind of SOCKs proxy.

3. Using Virtual Private Network (VPN): When you use VPN services, you simply connect to a different network and you get a different IP address that is set by the VPN server. This method is a better way to change IP address because VPN is able to give more reliable internet connection. That means almost all applications that connect to the internet can work without problems with VPN connections, without the need for extra configuration and applications. All are done automatically, it just looks like you are connecting under a normal internet connection. Hotspot Shield is such type of application.

4. Onion Routing: I personally like its algorithm. People who are serious about anonymity generally use things like onion routing through a bundled browser within a VM with a spoofed user agent. It takes very little to set up and, if done properly, it is nearly impossible to unmask.

In some cases, your IP address may be located all around the world. And if then you use a fake IP address located outside your country then it is possible that you will suffer from a slow browser. If you belong to such a category then it is advisable to look for the programs which offer the facility of providing IP addresses all over the world.

Looking back (May 02, 2020. After almost 7 years): For that one whole weekend, I kept playing with the router in our apartment and my room-mate, my friend and brother Sonal kept getting patiently mad because of disruption. On Sunday afternoon, he slept in his room and again I started doing my playing around with the router and unknown to me, I found him standing over my shoulder, where he was watching at me with a confused look, did his friend get possessed by a networking spirit. Did I get to know everything, I had intended to? Nope, just a tiny bit of theoretical but yeah I now knew how to f**k with the router and get it back from dead, that's all :-D

Thursday, November 22, 2012

Monitoring battery status on Linux using python

On laptops powered by Linux, the battery status is exposed by the kernel using the file on /proc pseudo filesystem. The file that you could use to monitor on most laptops is /proc/acpi/battery/BAT0/state. Listed below is a simple python code snippet that scans this file every 1 second, collects the necessary statistics and prints the remaining charge on your laptop battery.


You can customise this code or optimise it to your liking. For convenience, you can add this script to your startup applications. So whenever you log in to your lappy, it gets auto started. You can also modify it to show you the alert to unplug your laptop from the AC adaptor when the battery is full.