How to get root shell in Ubuntu GNU/Linux

A lot of my friends has been asking me about this very question, “how to get root shell in Ubuntu”. Naturally I would ask them to use the “sudo” command as it suffice to execute any task restricted to root only. It is explicit, and it is safer than using root account, that’s why ubuntu never prompted root password during installation.

However for some reasons, some people would prefer a full root shell instead of using “sudo” command. And here is how to obtain root shell access in Ubuntu GNU/Linux.

Method 1

From Desktop, launch the “Terminal” application, accesible through clicking Applications->Accesories->Terminal.

Execute this command,

mypapit@enterprise:~$ sudo -s
Password:

Enter your user password, and then you’ll get the root shell “#”.

Method 2

Same as method 1 but execute this command,

mypapit@enterprise:~$ sudo su
Password:

Enter your user password, and then you’ll get the root shell “#”.

So there you go, that’s how to get root shell access within your Ubuntu GNU/Linux. But as for me, I think I can settle with the sudo command, as I haven’t found a situation where I need to use the root shell explicitly.

Good luck !

Making money with Free and Open Source Software

Ever wonder how do you make money with Free and Open Source Software? I found an article which has a list of examples on how you can earn money through free and open source software model. It is an inspirational article indeed, you might get some ideas on how to start a business based on one of these examples.

Hope you enjoy reading it as I am!
101 Ways to Make Money off Open Source

p/s: the article only listed 46 examples instead of the implied 101.

Sending HTTP POST with php cURL

As promised previously, I’m going to show you how to send HTTP POST request using php cURL extension.

The target form

Let’s say you have a html form like this :

wtf

And this is the source code of the html file :


You can see that the form will submit the query using HTTP POST to “target.php”. Now let’s say you want to write a php script (bot.php) that will automatically send the query bypassing the html form, this is one way to do it (with php libcurl extension)

< ?php
//bot.php
$url = "http://localhost/wtf/target.php";
$ch = curl_init();

// set the target url
curl_setopt($ch, CURLOPT_URL,$url);

// howmany parameter to post
curl_setopt($ch, CURLOPT_POST, 1);

// the parameter 'username' with its value 'johndoe'
curl_setopt($ch, CURLOPT_POSTFIELDS,"username=johndoe");


$result= curl_exec ($ch);
curl_close ($ch); 
print $result;

?>

This script will send a HTTP POST request to “target.php” pretending to be a real person sending the “username” parameter as “john doe”.

However this is not entirely convincing since the server side will automatically know that you are using a http script to send the HTTP POST request by analyzing the browser “user-agent” string. The default script will send “(HTTPRetriever/1.0)” as its user-agent.

With a little add-on, you can spoof the user-agent string inside your script just like this :

< ?php
//
// test HTTP POST submitter, using libcurl
//

// the target url which contains scripts that accepts post request
$url = "http://localhost/wtf/target.php";

// we are spoofing Yahoo Seeker bot >:)
$useragent="YahooSeeker-Testing/v3.9 (compatible; Mozilla 4.0; MSIE 5.5; http://search.yahoo.com/)";

$ch = curl_init();

// set user agent
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);

// set the target url
curl_setopt($ch, CURLOPT_URL,$url);

// howmany parameter to post
curl_setopt($ch, CURLOPT_POST, 1);

// the parameter 'username' with its value 'johndoe'
curl_setopt($ch, CURLOPT_POSTFIELDS,"username=johndoe");


// execute curl,fetch the result and close curl connection
$result= curl_exec ($ch);
curl_close ($ch); 

// display result
print $result;

?>

so when your “bot.php” sends the request, the server logs will record that the query was sent by a “Yahoo Seeker bot” instead of a crudely coded php script.

You can spoof other browser as long as you know their user-agent string, refer to my previous post for a collection of browser user-agent strings.

No PHP cURL support?

In this case, you have a few options

  1. Use a server that support php cURL extension
  2. Compile/Install php cURL extension
  3. Use libcurlemu – php cURL extension written in pure php

Well that should cover the short crash course on how to use php cURL extension.

p/s : Although I won’t tell you how to write one directly, this is the basic of building spam bots and auto-submitter. So use your imagination (and the dark side of the force) to write the rest of the code. *evil*

You can download the source code of this tutorial here : http://mypapit.net/pub/libcurltest.zip

php,curl,webdev,libcurl,bots

How to Recover Scratched CDs


scratched cds
Ever been in situation where you need to install softwares from an old CD-ROM, or perhaps retrieve backups of your works? It must be a frustrating experience when you found out that your data couldn’t be retrieved because the CDs has been scratched. While preventing scratches may avoid this sort of problem, let face it, scratches may appear on your well stored CD/DVD as well.

The article I found below discussed on ways to recover from scratched CD-ROM, with a few tips and guides how to look for scratches to the final step of recovering data from it. Trust me, you may need this tip someday : Recovering Scratched CDs

cd, cd-rom, dvd, recovery,computer

libcurlemu – a pure PHP curl implementation (libcurl emulator)

Have you came across a situation where you need to use php libcurl extension and it was not enabled on your webserver? Then, try libcurlemu, apure-PHP implementation to PHP cURL. It emulates all of the curl_* functions normally provided by the native cURL extension itself.

libcurlemu works transparently regardless of the availability of PHP cURL extensions, thus making your script even more portable across web server that does not have PHP cURL extensions.

What is libcurl / cURL?

cURL is a command-line tool that supports transfering files with URL syntax. It supports many protocols like FTP, FTPS, TFTP, HTTP, HTTPS, TELNET, DICT, FILE and LDAP.

libcurl is a library based on cURL that helps you to connect and communicate with different type of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, and ldap protocols.

For HTTP/HTTPS protocol, libcurl supports POST, PUT, GET and DELETE method, making it suitable for writing web services, particularly REST-like services.

Stay tune for code examples on how to use libcurl to emulate a browser submitting POST request to a server.

libcurlemu is written by Steve Blinch, and can be downloaded at his website : http://code.blitzaffe.com

php, libcurl, curl, rest, opensource

Create your own Debian/Ubuntu (*.deb) package

mypapit debianI’ve found a nice well-written guide that may be useful for those who wants to create Debian *.deb package. Though compiling applications/software/libraries right from sources are desireable for some people, there’s still lots of others who prefer to install stuffs software packages for conveniency.

Why do you want to create Debian (*.deb) packages

There’s many reasons for you to create *.deb packages, one of it if you are (or want to be) a maintainer for a Debian-based project, or merely maintaining a unofficial packages for Debian-based system.

The guide would be useful if you are a software developer or in charge of distributing softwares in pre-package form to various GNU/Linux distribution. Creating a prepackage *.deb files will help people install your software without the need of developments tools and save compiling time, this is important since there are people who like to manage installations using software management tools such as synaptic and aptitiude.

Though most people would prefer to distribute binary only *.deb package, the practice of distributing pre-packaged source codes in *.deb format is not uncommon in Debian-based distro scene.

Here’s the link to the guide that I’m talking about :

  1. Rolling your own Debian packages (part 1)
  2. Rolling your own Debian packages (part 1)

Other Links :

  1. Debian New Maintainer website
  2. Debian Binary Package Howto
  3. Create Debian GNU/Linux Package

debian, ubuntu, linux, package, deb, repository, repositories