Wednesday 14 September 2016

Make programs startup on boot on Linux

For all of you who have servers out there, you know a reboot is sometimes unavoidable, and in most modern systems it is as simple and painless as sudo reboot now  or on some other systems sudo shutdown -R now  (I think?!?), anyway, sometimes these machines reboot on their own, maybe a software update went through, or some program thought it funny to send the reboot command, in any case it does happen. And then you get that lovely call from the clients "it's not working" and you can't figure out why the webpage isn't showing but you can ssh into the box fine and the firewall is allowing all the right traffic.  (if ofcourse it is running). So you use the top  command to see if you have some form of malware, and lo and behold you see uptime is 1 hour, the system rebooted and your web server isn't running, you start the web server and there we go problem solved. Which brings us into the reason for this post how to make it run on startup...

Now because I am pretty stupid myself I couldn't just read one tutorial, no, I read them all! and I am going to try and show you the simplest and easiest way of doing it, but first let's discuss runlevels, a deceptively simple concept, that I couldn't wrap my head around. runlevels are basically a state the machine is in, such as state 0. halt. which basically means the system is about to shutdown now. There are usually 7 run levels numbered from 0 - 6 (programmers are iffy about where we start counting), as I already mentioned 0 which means the system is going to shutdown, there is 6. Reboot, which is pretty obvious, it is the state of the machine right before a reboot, it is said to be in runlevel 6. I am going to use Centos as the linux OS here but the ideas apply almost universally. Centos inherits the following runlevels from RHEL:

  • 0 — Halt
  • 1 — Single-user text mode
  • 2 — Not used (user-definable)
  • 3 — Full multi-user text mode
  • 4 — Not used (user-definable)
  • 5 — Full multi-user graphical mode (with an X-based login screen)
  • 6 — Reboot

Now I don't think I am going to go indepth of what each one means but here are the basics, when the systems boots into single user no-network, no GUI mode (usually for diagnostics), it runs in level 1 obviously until the shutdown or reboot command is called where it is briefly in either runlevel 0 or 6 before it goes down. runlevels 2 and 4 are not used (these can actually be customised). The machine is said to run in level 3 when it is booted in multi user mode with networking but no GUI, meaning it only has terminals. This is sometime used in Server environments as GUI is computationally expensive and really unnecessary. But for most people when they startup their Centos machine it starts in level 5 which has all the bells and whistles including X server which gives you a pretty GUI to look at.  Now the important thing to know here is that the init process calls services and scripts to start according to runlevels. for example init will call all the services neccessary in runlevel 3 to have multiple users log on. but it won't actually call any GUI services. These it will only call in level 5. Init does its runlevel magic as soon as the system goes into a runlevel. From there it allows the user to start and stop whatever they want. How is this helpfull? well you can tell the system that you want your script to start at whichever runlevel you want, making it really simple to have a custom program run when the machine is booted or hell even as soon as the shutdown command is sent. To do this there are basically two major steps: create the init.d script and add this script to the right runlevels. now for this post I am going to make Tomcat start on boot. (the following assumes you are root or atleast have sudo privileges)

Create init.d script
This is a basic startup shell script that shows the machine how to start your program and where to find it. for tomcat I have the following script.



#!/bin/bash
# chkconfig: 2345 80 20
# Description: Tomcat Server basic start/shutdown script
# /etc/init.d/tomcat -- startup script for the Tomcat servlet engine

TOMCAT_HOME=/opt/tomcat/bin
START_TOMCAT=/opt/tomcat/bin/startup.sh
STOP_TOMCAT=/opt/tomcat/bin/shutdown.sh


start() {
echo -n "Starting tomcat: "
cd $TOMCAT_HOME
${START_TOMCAT}
echo "done."
}

stop() {
echo -n "Shutting down tomcat: "
cd $TOMCAT_HOME
${STOP_TOMCAT}
echo "done."
}

case "$1" in

start)
start
;;

stop)
stop
;;

restart)
stop
sleep 10
start
;;

*)
echo "Usage: $0 {start|stop|restart}"

esac
exit 0

Edit the highlighted part to point to your tomcat installation (or the start and stop scripts of your program)  and then save this as /etc/init.d/tomcat. Then we have one more command to make this script accessible to anyone.
chmod 755 /etc/init.d/tomcat

Now that we have this script we have one more command to run to add it to the correct runlevels
chkconfig --add tomcat 

 To check that the runlevels are correct run 
 chkconfig  --list tomcat
It will produce something like this:
tomcat 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Where it shows at which runlevels this script is on or off
 
To test this script you can try
service tomcat start
or
service tomcat stop
or
service tomcat restart 

To have a little bit more control over which runlevels your script runs in, is simple:
chkconfig --level 345 tomcat on
 
This switches tomcat on for levels 3,4 and 5.
And there you go creating a custom init script and making it run on boot.
 
I hope this helps you guys gain a little more control over your machines, if you have any questions, you are welcome to leave a comment or drop me an email.
Happy Hacking
MiniMite
 
 
 
 

Sunday 24 January 2016

How to access the deep web.

The other day I succumbed to my own curiosity and for no particular reason looked up how to access the deep web. I was surprised at how easy it was! And I will tell you how in this post.

But first a warning. Accessing the deep web itself may not be illegal but many, many of the sites there are! The deep web is where you can find drugs, child pornography, hit men, snuff films and many other nauseating sites that are most definitely NOT legal. And many of these sites are monitored by law enforcement agencies around the world to see who visits and what they do. So be careful what you look at! Beyond the very obvious legal and moral ramifications of visiting said unsavory sites there is also the psychological danger of seeing something that you can never 'un-see'.

You still want to see what is going on in there? okay well let us start. First a little bit of an overview, deep web sites tend to have unreadable URL's and end in .onion.  e.g. h87ho876gf08b487634gfo87.onion. Because of some of these sites being illegal they tend to move around a lot, meaning url's can change overnight, and finding one specific site can be confusing and quite hard. The deep web functions as a very very large (much larger than the visible web) peer-to-peer network, much like torrents. So obviously one can't access it with a normal browser a special browser is needed.

I will not go into detail about how to stay anonymous out there or how to stay safe (relative term on the internet), but I do suggest getting something like myIPHide and perhaps MAC address spoofing. But to just access the deep web you need a special browser called a tor browser. you can find one here.

After you have installed your tor browser, you can open it, and it will connect to the tor network. At this point , you can still google stuff, and go on your favourite surface web sites.
Now you want to find a deep web search engine or url repository. There is one on the surface web called the hidden wiki. You can find it here. 
From here you start seeing a listing of funny website names like I described earlier, these are deep web sites.

WELCOME TO THE DEEP WEB!

From here I suggest you either go to the uncensored hidden wiki (here you can get a good overview of the types of sites you can find on the deep web) or you can use a search engine to search for something. DuckDuckGo (first on the wiki listing) is a good search engine.  And that is all you need to know to access the deep web.

as always
Happy Hacking (and be careful)
MiniMite   

Sunday 10 November 2013

How to edit id3 tags of read only mp3 files

So this is the situation, i downloaded some mp3 files and imported them to my iTunes but I couldn't edit its information, it was all greyed out.

I started playing around with the files, and I found that they were all read only, I could go through every files properties and make them editable but this is a very long and tedious process. And like any good hacker out there knows, if you have to do the same thing over and over again, just write a program. And this is what kept me busy today, I wrote a simple program that opens the mp3 file and lets you edit the id3 tags (artist, title etc.) whether or not they are read only, the program can also remove the read only property.

It is called Mp3Tag and can be downloaded here.
Mp3Tag with dotnet installer
Mp3Tag without dotnet installer

You will see that there are 2 download links, one is just the program and the other has the .net 4.5 offline installer included(necessary for the program to run). if you already have .net 4.5 installed on your system, you only need the program, which is a lot smaller download.

After you have downloaded the programs, you unzip the file and you will finda file called dotnet 4.5 and a folder called Mp3Tag. Double click the dotnet 4.5 file, this will start the installation of dotnet, after you have installed dotnet, copy the Mp3Tag folder to where you want and inside you will see an executable called Mp3Tag.exe, run this and the program will open up, this is what you will see.

Now click on the open button and a open file dialog will open up, select the mp3 file you want to open.

This will open the mp3 file, from here, you can play, edit and even set the read only property of the mp3 file.
After you have edited the information, remember to press update to save the changes to your file.
the next time you open the song in itunes or any media player, it will have your new tags.

And there you have it, how to edit the id3 tags of read only mp3 files.

I am still working on editing more than one file at a time. but will post as soon as its done.

ps. comment on what you struggle with aswell as what you would like to see in this program in the future.

Happy Hacking
MiniMite



Saturday 9 November 2013

How to create a testing ground for your websites

This is for all you aspiring web developers and web hackers. The hardest thing to do is test a website that you wrote before deploying it to the webserver, yes you can run the html files with your browser, but what about php files? or other server side scripts or programs? these are slightly harder to test.
In this tutorial I will show you how to create a server running on your local machine that you can create full website and run them on your local machine. installing a webserver can also help you understand what happens on the other side, how do webservers work and so on. And it also makes it easy to install content management systems like Joomla! and Drupal to test and play with.

First off we will need to download and install server software, we will use the wamp server package that includes the apache server, mysql, php and phpMyadmin. this is basically all you will need to start your own webserver on your computer. you can download wampserver here.

While installing just accept all the default settings. after installation open your browser and in the address bar type localhost it will open up a page like this:


 When you typed localhost it opened up the default page for the website in the apache www directory, you can find this directory if you click on the 'www directory' in the taskbar menu for wampserver:


This opens up a folder on your local computer with 2 php files called: index.php and testmysql.php. You can't open the files from here, because your computer has not associated a program with the filetype, but dont worry you don't need to.

This is the main directory for your sites, remember not to delete these two files, as they are critical to wampserver. but you can create a folder, lets call it mysite, then if you type in localhost/mysite in your browsers address bar, it will open up the default page in this folder, the main page of your site.

I am not going to explain how to write a php or html file but the following site can teach you everything you will ever need to know about writing your own website for free: w3schools

Now the first thing you will want to do is create a database for your site right?
open localhost in your browser, and click on phpmyadmin under tools.

PHP my admin

This is what you will see when you open phpmyadmin. This is your control panel for all databases on the server and this is also where you will create your own database, go to the top right and click on Databases, the following window will open up:

Create new database

Type in a new name for your database and click on the create button, from there just follow the steps, it is all pretty self explanatory.

And there you go, a webserver with a database, on this database you can install a content management system like Joomla! or Drupal, or just use it to store data from your website.



Coming soon: How to create your own joomla site

ps. post any problems you have in the comments, I will see if I can help.

Happy Hacking
MiniMite

Profesional onscreen video capture

As promised here is my post about onscreen video capture, so we all now know how to take proper screencaptures. But how do they make those cool YouTube videos of someone working on their computer?

Well this is what i am going to give you today, a free, opensource tool to record all or just parts of what you see on screen.

Download CamStudio here:

Download the CamStudio software from their website, and run the installer.

Make sure you are connected to the internet while installing, CamStudio may want to download some dependencies.

After installing open CamStudio, a small window will open up, in the top menu bar go to the region menu, there you will see 4 options, 'region', 'fixed region', 'window', and 'fullscreen'.

region: gives you option to select region to capture before recording
fixed region: gives a standard size region that you can place where you want to record.
window: will give you the option to select only one window to capture, regardless of its position or size or what happens outside of it.
fullscreen: captures everything on your screen.

This should be enough to get you started recording your onscreen shenanigans.

ps. there are many programs to capture your onscreen activity, with many fancy settings and stuff, but many of them are not free to use as you wish, CamStudio is. and also it has many features that prove to be very helpful, like annotations, auto panning(window follows mouse movements), and different output formats, different screen resolutions etc.

Happy Hacking
MiniMite