Why are Java applications blocked by your security settings, and How do you bypass that

This is an article written by Oracle, hosted here

I face this issue in my work and this guide came to the rescue.
As part of my job, I frequently need to remote into UAT servers, hosted on a secured network, via a Java web interface. Things have been working well until the latest update of JRE to version 7 update 51. Since then, I have been always prompted with an error saying “Missing Application-Name manifest attribute for:” and the connection cannot be established.
From this Oracle article I realize the error is because the aforementioned web program is Self signed. No hush, this is an Intranet program and provided by my trusted partner so I am willing to run this program, and accept its “risk”.
Now, what I need to do is adding the URL into an Exception Site List so Java doesn’t strictly block anything coming from this site.
Here is the guide, copy here for reference :

WORKAROUND

It is highly recommended not to run these kind of applications, however if you still want to run, run only if you understand risk and implications involved.
As a workaround, the user can use Exception Site list feature to run the applications blocked by security settings. By adding the URL of the blocked application to the Exception Site list allows it to run with some warnings.

Steps to Add URL to the Exception Site list:
- Go to the Java Control Panel (On Windows Click Start and then Configure Java)
- Click on the Security tab
- Click on the Edit Site List button
- Click the Add in the Exception Site List window
- Add url to Exception Site list
Click in the empty field under Location field to enter the URL
Example: http://www.example.com
( URL should begin with http:// or https://)
Java_add_url

If the URL where the applet is hosted is different than the URL for the page on which the applet is called you need to add both the URL for the applet.
Example: For Yahoo games Checkers (This is just an example the host url can be different for depending on which host is serving the game), enter:
http://www.games.yahoo.com and (This is the url for Yahoo games domain)
http://yog36.games.sp2.yahoo.com (This is the url where game is the hosted and is shown in the dialog box for blocked application)

- Click OK to save the URL that you entered.
- Click Continue on the Security Warning dialog

Resolving Cisco VPN connection Error 412:The remote peer is no longer responding

I encounter this annoying error every time I connect to VPN via Cisco VPN Client v5.0.07.0290, running on Windows 7 and Windows XP.

Finally, found a solution somewhere on the Internet, pretty simple :

1. Go to Computer Services, by
a. issuing command services.msc in command prompt, OR
b. right clicking My Computer -> Manage -> Services and Applications -> Services
2. Stop the Cisco Systems,Inc.VPN service

Service_Cisco

Stop Cisco Systems service

3. Stop the Internet Connection Sharing (ICS) service
4. Right click on ICS service and choose Properties -> change Startup type to Disabled or Manual.

Program Manager_ICS

Change ICS Service service

5. Start Cisco Systems,Inc.VPN service

Done. Work like a charm.

How to logoff remote desktop sessions via command line tools?

Copy and re-post from here : http://anandthearchitect.com/2008/08/01/how-to-logoff-remote-desktop-sessions-via-command-line-tools/

To query and list the sessions on the remote session, you could use QUser.exe or QWinsta

1. QUser

QUser command comes with all the latest Windows clients and servers. This will list the sessions of the remote server (or local machine).

NOTE: if you are using Windows XP, you need to add this location into your System path: C:WindowsSystem32DLLCache. To do this, in command prompt, type the following.

SET PATH = %PATH%;C:WindowsSystem32DLLCache;

QUser help shows,

C:Anand>QUser /?
Display information about users logged on to the system.

QUERY USER [username | sessionname | sessionid] [/SERVER:servername]

username Identifies the username.
sessionname Identifies the session named sessionname.
sessionid Identifies the session with ID sessionid.
/SERVER:servername The server to be queried (default is current).

E.g.,
C:>quser /server:MyCitrixSVR
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME
johndoe ica-tcp#966 10 Active 7 7/31/2008 3:04 PM
averagejoe ica-tcp#969 1 Active 9 7/31/2008 3:30 PM
familyman ica-tcp#984 5 Active 1:06 7/31/2008 4:33 PM
normaldude ica-tcp#987 2 Active 4 7/31/2008 6:20 PM

2. QWinsta

QWinsta is little different and better. It has more features and options. It comes with all flavors of Windows. QWinsta command line help displays as,

C:>qwinsta /?
Display information about Terminal Sessions.

QUERY SESSION [sessionname | username | sessionid]
[/SERVER:servername] [/MODE] [/FLOW] [/CONNECT] [/COUNTER]

sessionname Identifies the session named sessionname.
username Identifies the session with user username.
sessionid Identifies the session with ID sessionid.
/SERVER:servername The server to be queried (default is current).
/MODE Display current line settings.
/FLOW Display current flow control settings.
/CONNECT Display current connect settings.
/COUNTER Display current Terminal Services counters information.

E.g.,

C:>qwinsta /server:citrixserver
SESSIONNAME USERNAME ID STATE TYPE DEVICE
0 Disc rdpwd
ica-tcp 65536 Listen wdica
rdp-tcp 65537 Listen rdpwd
console 16 Conn wdcon
ica-tcp#966 johndoe 10 Active wdica
ica-tcp#969 apple 1 Active wdica
ica-tcp#984 averagejoe 5 Active wdica
ica-tcp#987 familyman 2 Active wdica
ica-tcp#989 whoisme 3 Active wdica

You are welcome to try the other options QWinsta provides.

Logoff the Remote Sessions

To Log off the terminal session of the remote server, you can use any one of two command line tools. One of LOGOFF and another one is RWINSTA. Before you log off the remote session, you should know the “Session ID” which you get it from “QUSER” OR “QWINSTA” commands as above stated.

1. Logoff

Logoff command kicks off (logging off) the specified remote session. Log off help shows,

C:>logoff /?
Terminates a session.

LOGOFF [sessionname | sessionid] [/SERVER:servername] [/V]

sessionname The name of the session.
sessionid The ID of the session.
/SERVER:servername Specifies the Terminal server containing the user
session to log off (default is current).
/V Displays information about the actions performed.

E.g.,

C:>logoff /server:infra-apps 1 /v
Logging off session ID 1

2. RWinsta

RWinsta has same parameters and does same thing as log off command. It simply means Reset WINdows STAtion. The help goes as,
C:>RWinsta /?
Reset the session subsytem hardware and software to known initial values.

RESET SESSION {sessionname | sessionid} [/SERVER:servername] [/V]

sessionname Identifies the session with name sessionname.
sessionid Identifies the session with ID sessionid.
/SERVER:servername The server containing the session (default is current).
/V Display additional information.

E.g.,
C:>RWinsta /Server:MyWinServer 1

Note: RWinsta command does not return anything.

Happy Re-setting the remote sessions (Hey, stop cursing your co-workers who didn’t log off their sessions).

How do you start to decode a given gibberish string ?

What is a possible encoding for some string ended with an equal sign “=” ?
Base64, or base32

A quote snippet from Thomas Hobbes’s Leviathan:

“Man is distinguished, not only by his reason, but …”

represented as an ASCII byte sequence is encoded in MIME’s Base64 scheme as follows:

TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCAuLi4=

In the above quote the encoded value of Man is TWFu. Encoded in ASCII, M, a, n are stored as the bytes 77, 97, 110, which are 01001101, 01100001, 01101110 in base 2. These three bytes are joined together in a 24 bit buffer producing 010011010110000101101110. Packs of 6 bits (6 bits have a maximum of 64 different binary values) are converted into 4 numbers (24 = 4 * 6 bits) which are then converted to their corresponding values in Base64.

Text content M a n
ASCII 77 97 110
Bit pattern 0 1 0 0 1 1 0 1 0 1 1 0 0 0 0 1 0 1 1 0 1 1 1 0
Index 19 22 5 46
Base64-encoded T W F u

As this example illustrates, Base64 encoding converts 3 uncoded bytes (in this case, ASCII characters) into 4 encoded ASCII characters.

[Wikipedia]

What is a possible encoding for some pretty short, and fixed length string ?
Most likely it is in some kind of hash.
Hashing’ beauty is regardless of the length of the original text passage, once hashed, the encoded string is of fixed length.

Common hashing algorithms:
* MD5 : hashed string is 32 bit long
* SHA-1: hashed string is 40 bit long
(you can try out)

What I did to set up my RaspPi

1. Install RaspBian (using New-Out-Of-Box package)
2. get wireless to work on my Pi
2a. get my Pi to connect to Mac via Ethernet
2b. get Mac to share internet to my Pi via Internet Sharing
3. Configure to reserve the IP address for my Pi
4. Update access port for SSH
5. Configure NAT / Firewall in my LAN router to allow SSH to PI
6. Install lynx, mail, ssmtp => write script to auto capture router’s IP and email to my email acct every 1 hours . This can be used to SSH to my Pi in case the ISP changes router’s IP.
7. Install pyload (for direct file download)
8. Install Deluge (for Torrent)
9. Configure NAT / Firewall in my LAN router to allow public access to pyLoad+Deluge Web interface

Step 2a.
While I want Pi is connectable to my Mac via Ethernet, I also want to ensure my Mac can still connect to my home wireless network normally.
Hence, I set my Mac <-> Pi connection under a separate network segment that the home wifi.

Home wifi : 192.168.1.xxx
Ethernet connection : 192.168.2.xxx
>> fix my Mac to 192.168.2.1, DNS 8.8.8.8
>> fix my Pi to 192.168.2.104, gateway 192.168.2.1 (same as Mac fixed IP)

Home Wifi setup

Ethernet setup-network segment with Pi

/etc/network/interfaces: set static IP for Pi

Step 2b.
There are several tutorials online saying a simple Internet sharing ( Preferences -> Sharing -> Internet Sharing, Share your connection from Wifi, To computers using Ethernet) would get your Mac to share its Wireless Internet access to Pi.
I tried. Doesn’t work, not as simple.
Finally found this article which explains that the internet connection is indeed provided by my ROUTER, not my Mac. Hence, I need an additional step on Pi to add my router ip to Pi’s /etc/resolv.conf
nameserver 192.168.1.254

Set Interface sharing on Mac

Add router address to resolv.conf

Once that’s done, reload network service :
sudo /etc/init.d/networking reload

And … tada, ping www.google.com returns the sweet response.

My journey to get ruby on rails set up

–Update 22/Aug/2013
Screw all the steps below, I still got stuck after all those steps.
Now after a few miserable days trying to figure out how to move on, I stumbled upon this page : http://railsinstaller.org/en
Hell, this is my savior.
Installed the package from that site on my Windows machine, everything is setup, configured and I am good to go within 10′ .
Phew, finally I can start doing the REAL stuffs, coding.

–Jul 24, 2013
1. Install ruby : download from here. Get the latest version. I use Ruby 2.0.0-p247 .

2. Install Development Kit, download and instruction here

3. Install rails : open up command prompt and punch in :
$> gem install rails –backtrace

The –backtrace option shows stack backtrace on errors.
Note that installation would take some times so the screen may appear hanging, but it’s not. Go make a nice cup of coffee and come back later.
The screen may stay at “Installing ri documentation for rails-4.0.0″ for some times.
In fact, if you don’t need to download the documentation to local, you can skip using option –no-ri –no-rdoc

Optional: In case you want to know what’s going on in the background, you can use the -V option, but it would be overwhelming.

$> gem install rails -V –backtrace

The -V option enforces verbose mode and shows installation progress.

——
Set up the 1st test app
1. $> rails new path\to\first\testProj
2. $> cd path\to\first\testProj
3. $> rails server
Here, I have issue with in `require’: cannot load such file — sqlite3/sqlite3_native (LoadError)
Resolution is here http://rubyonwindowsguides.github.io/book/ch02-05.html

http://stackoverflow.com/questions/1152928/installing-sqlite3-on-windows-whats-the-current-easiest-route/1153014#1153014

—-
View current gem installed :
$> gem list

Validate whether sqlite3 is properly installed
$> irb
irb(main):001:0> require ‘sqlite3′

Uninstall sqlite3,
$> gem uninstall sqlite3
then install again with forced platform
$> gem install sqlite3 –platform=ruby

SQL script to capture row values into a single string

This script is useful when you need to concatenate a number of row values into a single string