<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-893514763189468960</id><updated>2011-11-27T19:04:20.392-04:30</updated><category term='Hacking'/><category term='Javascript Injection'/><category term='Security'/><category term='Javascript'/><category term='Linux'/><category term='Programming'/><category term='C'/><category term='tutorial'/><category term='Web Security'/><category term='Injection'/><title type='text'>3l_f3n1x</title><subtitle type='html'>In love with computers...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://3l-f3n1x.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/893514763189468960/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://3l-f3n1x.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>3l_f3n1x</name><uri>http://www.blogger.com/profile/09863936926085442492</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_STr-0tTLXc8/SeYuDRkMS7I/AAAAAAAAAAo/g6qSQ8K4CFY/S220/3l_f3n1x.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-893514763189468960.post-5642081202487889770</id><published>2009-04-14T21:52:00.008-04:30</published><updated>2009-04-14T22:43:46.866-04:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>C tutorial [Chapter 1]</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Introduction&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The purpose of this tutorial is to learn how to use C with some of its best features like pointers, process and thread creation, semaphores and signal handling. Of course to learn how to do all this we need to start from the beginning.&lt;br /&gt;This is not a basic programming tutorial. If you don't know how the art of programming works this is not a tutorial for you. C is a very complex language if you are a beginner. Try Python or even Java if you want to start with something easy then you will be prepared to learn this awesome language.&lt;br /&gt;I love Linux. Linux loves C. I don't know if any of the techniques exposed here work in a Windows machine... I really don't care if they work... Linux is a very efficient OS. I won't explain why, but in the references below, you will find the book that explains why any Unix based system is better than any flavor of Windows.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;In the beginning there was darkness&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Lets learn some syntax first:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Variable types&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;    int: Integer&lt;br /&gt;    char: Character&lt;br /&gt;    float: Float&lt;br /&gt;    char* or char[]: Strings&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Among others...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Assignment&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;    int intName = 10;&lt;br /&gt;    char charName = 48; // "0"&lt;br /&gt;    char* str1Name = "Hello World";&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;IF-ELSE IF-ELSE statements&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;    if(condition1){&lt;br /&gt;        Instructions&lt;br /&gt;    }else if(condition2){&lt;br /&gt;        Instructions    &lt;br /&gt;    ...&lt;br /&gt;    }else if(conditionN){&lt;br /&gt;        Instructions&lt;br /&gt;    }else{&lt;br /&gt;        Instructions&lt;br /&gt;    }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;Switch statements&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Faster than If statements&lt;br /&gt;&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;    switch(condition){&lt;br /&gt;        case 1:&lt;br /&gt;            Instructions&lt;br /&gt;            break;&lt;br /&gt;        ...&lt;br /&gt;        case N:&lt;br /&gt;            Instructions&lt;br /&gt;            break;&lt;br /&gt;        default:&lt;br /&gt;            Instructions     &lt;br /&gt;    }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Loops&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;While loop&lt;/span&gt;&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;    while(condition){&lt;br /&gt;        Instructions&lt;br /&gt;    }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;For Loop&lt;/span&gt;&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;    int i;&lt;br /&gt;    for(i=0; condition; i++){&lt;br /&gt;        Instructions&lt;br /&gt;    }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Do-While Loop&lt;/span&gt;&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;    do{&lt;br /&gt;        Instructions&lt;br /&gt;    }while(condition);&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Useful functions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Search in the man pages of your Linux distribution how to use them. In Debian you have to install them from the repositories.&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;apt-get install manpages-dev&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The functions you should man for now are:&lt;br /&gt;printf&lt;br /&gt;scanf&lt;br /&gt;strlen&lt;br /&gt;strcpy&lt;br /&gt;strcat&lt;br /&gt;malloc&lt;br /&gt;free&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Pointers&lt;/span&gt;&lt;br /&gt;The beautiful pointers... Thanks to them we have Orient Object Programming.&lt;br /&gt;Let's say this is our memory (All numbers in Hex with a Little-Endian 32 bits hardware):&lt;br /&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Endianness"&gt;Endianness Explanation&lt;/a&gt;&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://i384.photobucket.com/albums/oo287/etadel2/Screenshot.png"&gt;&lt;img style="cursor:hand;width: 239px; height: 180px;" src="http://i384.photobucket.com/albums/oo287/etadel2/Screenshot.png" border="0"/&gt;&lt;/a&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;Also lets say our program is:&lt;br /&gt;&lt;br /&gt;int a = 10; //Address 0x00&lt;br /&gt;int* b = &amp;a; //Address 0x04&lt;br /&gt;char* c = "HELLO"; //Address 0x08&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;b is a pointer. If I print b I will get 0x00000000&lt;br /&gt;which is the address of a. If I print *b I will print&lt;br /&gt;the value of the thing b is pointing, in this case a.&lt;br /&gt;So printing *b will result in 0x0000000A or 10&lt;br /&gt;If I print &amp;a I will get the address of a which is 0x00000000&lt;br /&gt;&lt;br /&gt;Now if I print c[2] I will get 4C which is L in the ascii table.&lt;br /&gt;If I print all the string, it will print till it gets to the null byte&lt;br /&gt;In this case the null byte is in the sixth byte of the string.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now you know how to get the information of a pointer :)&lt;br /&gt;To reserve memory use the function &lt;span style="font-weight:bold;"&gt;malloc&lt;/span&gt; like this:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;&lt;br /&gt;    char* str;&lt;br /&gt;    int* i; &lt;br /&gt;    /*&lt;br /&gt;    * To reserve 10 bytes for str. The (char *)&lt;br /&gt;    * is for the program to know what kind of &lt;br /&gt;    * pointer will be.&lt;br /&gt;    */&lt;br /&gt;    str = (char *)malloc(10);&lt;br /&gt;    /*&lt;br /&gt;    * To reserve enough space for a int I use the&lt;br /&gt;    * sizeof function.&lt;br /&gt;    */&lt;br /&gt;    i = (int *)malloc(sizeof(int));&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Precompiler Instructions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This are special instructions. All the calculations are made by the compiler, but make us the life easier.&lt;br /&gt;Include precompiler instruction&lt;br /&gt;It's to import the libraries you want to use in your program.&lt;br /&gt;For system libraries:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;#include &lt;stdio.h&gt;//This will include the stdio.h file.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;For user defined libraries:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;#include "list.h"//This will include the lis.h file.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Define precompiler instruction&lt;br /&gt;To define a constant:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;#define TRUE 1//This will define the word TRUE as 1&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The .h files are the headers files. There you'll have the firm of every function in the .c with the same name.&lt;br /&gt;&lt;br /&gt;sum.h&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;&lt;br /&gt;void printSum(int, int);&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;sum.c&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;&lt;br /&gt;#include "sum.h"&lt;br /&gt;&lt;br /&gt;int sum( int a, int b ){&lt;br /&gt;    return ( a + b );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void printSum(int a, int b ){&lt;br /&gt;    printf("The result is %d", sum( a , b ));//Prints result on screen&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;As you can see, the the sum.h only have the printSum function. This is because printSum is a public function while sum is just a private function. If someone use this useless library will not be able to use sum, but will be able to use printSum. So to define a class you should to use a header file. But how do you define a new data type? With Structures :)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Structures&lt;/span&gt;&lt;br /&gt;Let's say we want to define the data type Person (Name, Age, Gender)&lt;br /&gt;&lt;br /&gt;person.h&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;stdlib.h&gt;&lt;br /&gt;#include &lt;string.h&gt;&lt;br /&gt;&lt;br /&gt;struct PERSON{&lt;br /&gt;    char* pName;&lt;br /&gt;    int pAge;&lt;br /&gt;    int pGender;//0 for man, 1 for woman&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;typedef struct PERSON Person;&lt;br /&gt;&lt;br /&gt;Person* newPerson(char*, int, int);&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;person.c&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;&lt;br /&gt;#include "person.h"&lt;br /&gt;&lt;br /&gt;//Constructor of Person. Returns NULL on error&lt;br /&gt;Person* newPerson(char* name, int age, int gender){&lt;br /&gt;    /*&lt;br /&gt;    * To reserve some memory use malloc with the size you need&lt;br /&gt;    * In this case I need the space enough to hold a Person type&lt;br /&gt;    * so I use sizeof(Person);&lt;br /&gt;    */&lt;br /&gt;    Person* nPerson = (Person *) malloc(sizeof(Person));&lt;br /&gt;    //To access the members of this class we should use the "-&gt;" operator.&lt;br /&gt;    if(gender != 0 &amp;&amp; gender != 1){&lt;br /&gt;        free(nPerson);//To free the space used by nPerson&lt;br /&gt;        return NULL;&lt;br /&gt;    }&lt;br /&gt;    //To access the pGender, member of Person&lt;br /&gt;    nPerson-&gt;pGender = gender;&lt;br /&gt;    if(age&lt;0){&lt;br /&gt;        free(nPerson);//To free the space used by nPerson&lt;br /&gt;        return NULL;        &lt;br /&gt;    }&lt;br /&gt;    //To access the pAge, member of Person&lt;br /&gt;    nPerson-&gt;pAge = age;&lt;br /&gt;    /*&lt;br /&gt;    * With the function malloc I reserve as many bytes the char* name has and then&lt;br /&gt;    * and I assign the new address to the pName, member of Person. If the malloc &lt;br /&gt;    * return NULL the system call to ask some more memory failed, and the creation&lt;br /&gt;    * of the new type also should failed. It's efficient to free the space used for &lt;br /&gt;    * any reference data type if it won't be used anymore. That's why I use free(void*)&lt;br /&gt;    * everytime a inconsistent data or a failed system call appears.&lt;br /&gt;    */&lt;br /&gt;    if((nPerson-&gt;pName = (char *) malloc(strlen(name)))==NULL){&lt;br /&gt;        free(nPerson);//To free the space used by nPerson&lt;br /&gt;        return NULL;&lt;br /&gt;    }&lt;br /&gt;    /*&lt;br /&gt;    * This function copies name to pName&lt;br /&gt;    * This nPerson-&gt;pName = name would only copie the&lt;br /&gt;    * address of name to nPerson-&gt;pName&lt;br /&gt;    */&lt;br /&gt;    strcpy(nPerson-&gt;pName,name);&lt;br /&gt;    return nPerson;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;You can also use "." intead of "-&gt;", but you need to change some things... I think is easier to work this way...&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;Explanation of the code:&lt;/span&gt;&lt;br /&gt;Here I declare the members of the "class". In this case you have pName, pAge, pGender.&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;&lt;br /&gt;struct PERSON{&lt;br /&gt;    char* pName;&lt;br /&gt;    int pAge;&lt;br /&gt;    int pGender;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Here I rename the "class" from "struct PERSON" to "Person". It's just to write less code :)&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;&lt;br /&gt;typedef struct PERSON Person;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Then I declare the "constructor" of the "class"&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc;"&gt;&lt;br /&gt;Person* newPerson(char*, int, int);&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;End Chapter 1&lt;/span&gt;&lt;br /&gt;Chapter 2: fork() system call, signals, semaphores (ERROR 501: NOT IMPLEMENTED)&lt;br /&gt;Chapter 3: File Descriptors, Pipes (ERROR 501: NOT IMPLEMENTED)&lt;br /&gt;Chapter 4: Thread creation (ERROR 501: NOT IMPLEMENTED)&lt;br /&gt;Chapter 5: Security risks (ERROR 501: NOT IMPLEMENTED)&lt;br /&gt;Chapter 6: Networking (ERROR 501: NOT IMPLEMENTED)&lt;br /&gt;&lt;br /&gt;Thanks for reading :)&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;References&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This book is awesome. Everybody should read it :)&lt;br /&gt;&lt;a href="http://tinyurl.com/d6d3zk"&gt;Operating Systems: Internals and Design Principles by William Stallings&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The best search engine:&lt;br /&gt;&lt;a href="http://www.google.com"&gt;Google&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The best reference for C language:&lt;br /&gt;&lt;a href="http://www.debian.org"&gt;Debian&lt;/a&gt; man pages for development.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Endianness"&gt;Endianness&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/893514763189468960-5642081202487889770?l=3l-f3n1x.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://3l-f3n1x.blogspot.com/feeds/5642081202487889770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://3l-f3n1x.blogspot.com/2009/04/c-tutorial-chapter-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/893514763189468960/posts/default/5642081202487889770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/893514763189468960/posts/default/5642081202487889770'/><link rel='alternate' type='text/html' href='http://3l-f3n1x.blogspot.com/2009/04/c-tutorial-chapter-1.html' title='C tutorial [Chapter 1]'/><author><name>3l_f3n1x</name><uri>http://www.blogger.com/profile/09863936926085442492</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_STr-0tTLXc8/SeYuDRkMS7I/AAAAAAAAAAo/g6qSQ8K4CFY/S220/3l_f3n1x.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-893514763189468960.post-707460314931242919</id><published>2009-04-14T21:02:00.003-04:30</published><updated>2009-04-14T21:15:00.752-04:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Hacking'/><title type='text'>Avoiding Public Ridicule (Securely Erasing your Hard-Disk)</title><content type='html'>Let's say you bought a brand new hard-disk and you want to sell your old hard-disk to John Doe, a really good friend. Also let's say you have in your old hard-disk tons compromising photos, enough to fill the Internet with twice, of yourself wearing a pink thong while you are posing for the camera. You decide to erase your disk to prevent the public ridicule. After a few seconds you have erased your entire disk and it's ready to be sold.&lt;br /&gt;After a week, you enter in Google, but instead of the Google logo is one of those compromising photos, the worst of all of them. Suddenly, your cellphone starts to ring and you noticed your e-mail box is full... and almost all the subjects of all those e-mails start with &lt;span style="font-weight:bold;"&gt;"Hahaha"&lt;span style="font-style:italic;"&gt;&lt;/span&gt;&lt;/span&gt;. You answer your phone and you hear the voice of your good friend John Doe: &lt;span style="font-style:italic;"&gt;&lt;span style="font-weight:bold;"&gt;"Hahaha, you sick bastard!! Next time really erase your data, you idiot!!"&lt;/span&gt;&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;And all this could be avoided... How? Well, with a simple and nice tool called wipe.&lt;br /&gt;&lt;br /&gt;Lets say your old hard-disk is an IDE hard-disk and also is your primary disk with three partitions.&lt;br /&gt;&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: #cccccc"&gt;&lt;br /&gt;hda1 / Ext3&lt;br /&gt;hda2 /home Ext3&lt;br /&gt;hda3 swap&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Let's say you have a Linux LiveCD. You boot from it and install wipe (if it's not installed yet). Then erase every partition with it:&lt;br /&gt;&lt;br /&gt;Syntax:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: #cccccc"&gt;&lt;br /&gt;    wipe /dev/&lt;partition&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;For more information:&lt;br /&gt;    man wipe&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In our case:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: #cccccc"&gt;&lt;br /&gt;    wipe /dev/hda1&lt;br /&gt;    wipe /dev/hda2&lt;br /&gt;    wipe /dev/hda3&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Wipe's developers suggest only wiping one partition at a time&lt;/span&gt;&lt;br /&gt;Then if you want you can erase every partition.&lt;br /&gt;&lt;br /&gt;Now it's pretty hard to recover the information of the disk and you are a bit safer.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The moral of this little story: Never take compromising photos of yourself again&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Annexe&lt;/span&gt;&lt;br /&gt;If you want a LiveCD for free and without effort:&lt;br /&gt;&lt;a href="https://shipit.ubuntu.com/"&gt;Ubuntu LiveCD/&lt;/a&gt;&lt;br /&gt;Also you can donwload the iso image and burn it on a CD.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/893514763189468960-707460314931242919?l=3l-f3n1x.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://3l-f3n1x.blogspot.com/feeds/707460314931242919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://3l-f3n1x.blogspot.com/2009/04/lets-say-you-bought-brand-new-hard-disk.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/893514763189468960/posts/default/707460314931242919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/893514763189468960/posts/default/707460314931242919'/><link rel='alternate' type='text/html' href='http://3l-f3n1x.blogspot.com/2009/04/lets-say-you-bought-brand-new-hard-disk.html' title='Avoiding Public Ridicule (Securely Erasing your Hard-Disk)'/><author><name>3l_f3n1x</name><uri>http://www.blogger.com/profile/09863936926085442492</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_STr-0tTLXc8/SeYuDRkMS7I/AAAAAAAAAAo/g6qSQ8K4CFY/S220/3l_f3n1x.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-893514763189468960.post-6755486559117094807</id><published>2009-04-14T18:59:00.008-04:30</published><updated>2009-04-14T20:45:12.423-04:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Web Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Hacking'/><category scheme='http://www.blogger.com/atom/ns#' term='Javascript Injection'/><category scheme='http://www.blogger.com/atom/ns#' term='Injection'/><title type='text'>Don't be afraid of needles (JS Injection)</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Prologue and Disclaimer&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you don't know HTML, go and learn it before you read this.&lt;br /&gt;If you don't know javascript, I recommend you learn to read it at least.&lt;br /&gt;This text is for educational purpose, I am not responsible of what you do with this information. I just hope you stay in the Light Side of the Force.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;A Beautiful World&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When I was young and reckless (two years ago) and I was starting in the world of hacking I was amazed by a thing called javascript injections. I would never thought I could inject code into a page without any sophisticated tool, just my knowledge of javascript and my favorite browser firefox.&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;&lt;br /&gt;Know your World&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In your URL bar write:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc"&gt;&lt;br /&gt;javascript:alert("Hello World")&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;and then hit enter.You should see a nice little pop up that says Hello World.&lt;br /&gt;I will explain the code:&lt;br /&gt;1. javascript: - Introduces javascript code.&lt;br /&gt;2. alert() - This function makes that little pop up you saw before. The argument of the function is the message in the pop up.&lt;br /&gt;&lt;br /&gt;This function is very useful to see the information hidden from you, like cookies:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc"&gt;&lt;br /&gt;javascript:alert(document.cookie)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;1. document - represents the current page.&lt;br /&gt;2. document.cookie - represents the cookies for that page.&lt;br /&gt;This code would show your current cookies.&lt;br /&gt;&lt;br /&gt;Let's say we have this form:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc"&gt;&lt;br /&gt;1.   &amp;lt;form action="/Neo.php" method="post"&amp;gt;&lt;br /&gt;2.      &amp;lt;select name="message"&amp;gt;&lt;br /&gt;3.         &amp;lt;option value="Take the blue pill"&amp;gt;Take the blue pill&amp;lt;/option&amp;gt;&lt;br /&gt;4.      &amp;lt;/select&amp;gt;&lt;br /&gt;5.      &amp;lt;br&amp;gt;&lt;br /&gt;7.      &amp;lt;input type="submit" value="Send Message to Neo!"&amp;gt;&lt;br /&gt;8.   &amp;lt;/form&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In this case we do not want Neo to take the blue pill because we need him as the Chosen One. We need him to save us. So we have to send him a message that says "Take the red pill". There are several ways to do this(Two of them metioned below). I will explain the JS way.&lt;br /&gt;In your URL bar write this:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc"&gt;&lt;br /&gt;javascript:alert(document.forms[0])&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;1. document.forms[x] - represents a form in the current page being x the number of the form. If we have three forms, first one would be document.forms[0] and the last one document.forms[2].&lt;br /&gt;&lt;br /&gt;Now write:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc"&gt;&lt;br /&gt;javascript:alert(document.forms[0].elements[0])&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;1. document.forms[0].elements[0] - represents an element in the form. In our form we have two elements: select tag (document.forms[0].elements[0]) and input tag (document.forms[0].elements[1]).&lt;br /&gt;&lt;br /&gt;And now:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc"&gt;&lt;br /&gt;javascript:alert(document.forms[0].elements[0].options[0])&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;1. document.forms[0].elements[0].options[0] - represents an option in the select tag.&lt;br /&gt;&lt;br /&gt;In our form we have just one option and to see its value we do:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc"&gt;&lt;br /&gt;javascript:alert(document.forms[0].elements[0].options[0].value)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This code will alert "Take the blue pill".&lt;br /&gt;So we finally have access to the thing we want to change.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Change your World&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can skip this only if you fully understand it.&lt;br /&gt;&lt;div style="border: solid #cccccc;"&gt;&lt;br /&gt;Differences between = and == in common&lt;br /&gt;programming languages&lt;br /&gt;&lt;br /&gt;I will explain this with a little example:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc"&gt;&lt;br /&gt;&lt;br /&gt;1. var yoda = 1000;&lt;br /&gt;2. yoda = 200;&lt;br /&gt;3. if(yoda == 200){&lt;br /&gt;4.    alert("yoda rocks!");&lt;br /&gt;5. }else{&lt;br /&gt;6.    alert("Chimichanga!");&lt;br /&gt;7. }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In the first line = is used to asign 1000 to the variable yoda. With that I mean yoda's value is 1000. The same thing happens in the second line where 200 is asigned to yoda. Now the expresion (yoda == 200) works in this case like an equal sign. So if yoda equals 200 then that condition in the if statement is true and will alert that yoda rocks, else will alert Chimichanga. This code will always alert that yoda rocks because that's the last value asigned to the variable yoda.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;To change the value of a variable we use the void() function. Example:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc"&gt;&lt;br /&gt;1.   &amp;lt;html&amp;gt;&lt;br /&gt;2.      &amp;lt;head&amp;gt;&lt;br /&gt;3.         &amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;4.            c = 1000000;&lt;br /&gt;5.            function counter(){&lt;br /&gt;6.               document.getElementById('counter').innerHTML="Seconds left: "+c;&lt;br /&gt;7.               if(c==0){&lt;br /&gt;8.                  window.location="http://google.com";&lt;br /&gt;9.               }else{&lt;br /&gt;10.                 c=c-1;&lt;br /&gt;11.                 var time = setTimeout('counter()',1000);&lt;br /&gt;12.              }&lt;br /&gt;13.           }&lt;br /&gt;14.        &amp;lt;/script&amp;gt;&lt;br /&gt;15.     &amp;lt;/head&amp;gt;&lt;br /&gt;16.     &amp;lt;body onload="counter()"&amp;gt;&lt;br /&gt;17.        &amp;lt;div id="counter"&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;18.     &amp;lt;/body&amp;gt;&lt;br /&gt;19.  &amp;lt;html&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;If we want to visit google a bit faster we could do:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc"&gt;&lt;br /&gt;javascript:void(c=0)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can skip this if you fully understanded the code above.&lt;br /&gt;&lt;div style="border: solid #cccccc;"&gt;&lt;br /&gt;function counter() explained&lt;br /&gt;&lt;br /&gt;This function is a backwards counter that goes from 1000000s to 0s (about 11 days), so this means you can only access to google after 11 days you load the page. We see in the line 4 a global variable (variable c). That global variable is the responsible for the long wait to finally go to google. Our advantage here is the fact that the variable is global, so we can change it with a injection using the function void(). If we change the value of variable c to 0, we inmediately will be redirected to google.com. So that's why we use the injection javascript:void(c=0).&lt;br /&gt;&lt;br /&gt;If you don't understand the code and you want to fully understand it (it would be advisable) go to this page &lt;a href="http://www.w3schools.com"&gt;http://www.w3schools.com&lt;/a&gt; and learn some javascript.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;In our form we need to change the message and it is almost the same code above:&lt;br /&gt;&lt;div style="color: #cccccc; font-weight: bold; border: solid #cccccc"&gt;&lt;br /&gt;javascript:void(document.forms[0].elements[0].options[0].value="Take the red pill")&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;It seems we did not do much, but our form is now injected. If you hit "Send Message to Neo!", the form will send now the right message to our savior. :)&lt;br /&gt;And that Code Highlighting :: Select Code&lt;br /&gt;is the way to make the world a better place with JS Injections. :)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Summary&lt;/span&gt;&lt;br /&gt;- alert(something)&lt;br /&gt;something == String or something == variable&lt;br /&gt;- void(something = something_else)&lt;br /&gt;something == variable and something_else == new value for something&lt;br /&gt;- Enjoy :D&lt;br /&gt;&lt;br /&gt;If you want to know more about injections I recommend to learn javascript. This injections will make your life a bit easier.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Annex&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can make the same modifications to a form with firebug(Firefox extension) or copying the source code of the page in a text editor(notepad, gedit, vim, emacs, etc.), modify the code, save it in your computer(as html file if you are in Windows) and then submit the form(Remember to change the form's action from action="/Neo.php" to action="http://ChosenOne.org/Neo.php")&lt;br /&gt;&lt;br /&gt;Well, that's all folks! May the force be with you and accept Jesus Christ as your Savior!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/893514763189468960-6755486559117094807?l=3l-f3n1x.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://3l-f3n1x.blogspot.com/feeds/6755486559117094807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://3l-f3n1x.blogspot.com/2009/04/dont-be-afraid-of-needles-js-injection.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/893514763189468960/posts/default/6755486559117094807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/893514763189468960/posts/default/6755486559117094807'/><link rel='alternate' type='text/html' href='http://3l-f3n1x.blogspot.com/2009/04/dont-be-afraid-of-needles-js-injection.html' title='Don&apos;t be afraid of needles (JS Injection)'/><author><name>3l_f3n1x</name><uri>http://www.blogger.com/profile/09863936926085442492</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_STr-0tTLXc8/SeYuDRkMS7I/AAAAAAAAAAo/g6qSQ8K4CFY/S220/3l_f3n1x.png'/></author><thr:total>0</thr:total></entry></feed>
