Saturday, May 28, 2011

How to Install Python 3 in Linux

$ sudo apt-get install build-essential libncursesw5-dev libreadline5-dev libssl-dev libgdbm-dev libbz2-dev libc6-dev libsqlite3-dev tk-dev g++ gcc
Step 2: Grab the bits, extract them and build them

$ wget http://www.python.org/ftp/python/3.0/Python-3.0.tgz
$ tar xvzf Python-3.0.tgz
$ cd Python-3.0/
$ ./configure
$ make
$ sudo make install

Python 3.0 (r30:67503, May 29 2011, 02:31:02)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

Friday, April 29, 2011

Hacking Security Cameras Google Search Terms

inurl:ViewerFrame?Mode=
intitle:Axis 2400 video server
inurl:/view.shtml
intitle:Live View / - AXIS
inurl:view/view.shtml^
inurl:ViewerFrame?Mode=
inurl:ViewerFrame?Mode=Refresh
inurl:axis-cgi/jpg
inurl:axis-cgi/mjpg (motion-JPEG)
inurl:view/indexFrame.shtml
inurl:view/index.shtml
inurl:view/view.shtml
liveapplet
intitle:live view intitle:axis
intitle:liveapplet
allintitle:Network Camera NetworkCamera
intitle:axis intitle:video server
intitle:liveapplet inurl:LvAppl
intitle:EvoCam inurl:webcam.html
intitle:Live NetSnap Cam-Server feed
intitle:Live View / - AXIS
intitle:Live View / - AXIS 206M
intitle:Live View / - AXIS 206W
intitle:Live View / - AXIS 210?
inurl:indexFrame.shtml Axis
inurl:MultiCameraFrame?Mode=Motion
intitle:start inurl:cgistart
intitle:WJ-NT104 Main Page
intext:MOBOTIX M1? intext:Open Menu
intext:MOBOTIX M10? intext:Open Menu
intext:MOBOTIX D10? intext:Open Menu
intitle:snc-z20 inurl:home/
intitle:snc-cs3 inurl:home/
intitle:snc-rz30 inurl:home/
intitle:sony network camera snc-p1?
intitle:sony network camera snc-m1?
site:.viewnetcam.com -www.viewnetcam.com
intitle:Toshiba Network Camera user login
intitle:netcam live image
intitle:i-Catcher Console - Web Monitor
inurl:”ViewerFrame?Mode=
intitle:Axis 2400 video server
inurl:/view.shtml
intitle:”Live View / - AXIS” | inurl:view/view.shtml^
inurl:ViewerFrame?Mode=
inurl:ViewerFrame?Mode=Refresh
inurl:axis-cgi/jpg
inurl:axis-cgi/mjpg (motion-JPEG)
inurl:view/indexFrame.shtml
inurl:view/index.shtml
inurl:view/view.shtml
liveapplet
intitle:”live view” intitle:axis
intitle:liveapplet
allintitle:”Network Camera NetworkCamera”
intitle:axis intitle:”video server”
intitle:liveapplet inurl:LvAppl
intitle:”EvoCam” inurl:”webcam.html”
intitle:”Live NetSnap Cam-Server feed”
intitle:”Live View / - AXIS”
intitle:”Live View / - AXIS 206M”
intitle:”Live View / - AXIS 206W”
intitle:”Live View / - AXIS 210″
inurl:indexFrame.shtml Axis
inurl:”MultiCameraFrame?Mode=Motion”
intitle:start inurl:cgistart
intitle:”WJ-NT104 Main Page”
intext:”MOBOTIX M1″ intext:”Open Menu”
intext:”MOBOTIX M10″ intext:”Open Menu”
intext:”MOBOTIX D10″ intext:”Open Menu”
intitle:snc-z20 inurl:home/
intitle:snc-cs3 inurl:home/
intitle:snc-rz30 inurl:home/
intitle:”sony network camera snc-p1″
intitle:”sony network camera snc-m1″
site:.viewnetcam.com -www.viewnetcam.com
intitle:”Toshiba Network Camera” user login
intitle:”netcam live image”
intitle:”i-Catcher Console - Web Monitor”

Wednesday, March 30, 2011

Install Python from Source

localhost:~$ su −
Password: [enter your root password]
localhost:~# wget http://www.python.org/ftp/python/2.3/Python−2.3.tgz
Resolving www.python.org... done.
Connecting to www.python.org[194.109.137.226]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8,436,880 [application/x−tar]
...
localhost:~# tar xfz Python−2.3.tgz
localhost:~# cd Python−2.3
localhost:~/Python−2.3# ./configure
checking MACHDEP... linux2
checking EXTRAPLATDIR...
checking for −−without−gcc... no
...
localhost:~/Python−2.3# make
gcc −pthread −c −fno−strict−aliasing −DNDEBUG −g −O3 −Wall −Wstrict−prototypes
−I. −I./Include −DPy_BUILD_CORE −o Modules/python.o Modules/python.c
gcc −pthread −c −fno−strict−aliasing −DNDEBUG −g −O3 −Wall −Wstrict−prototypes
−I. −I./Include −DPy_BUILD_CORE −o Parser/acceler.o Parser/acceler.c
gcc −pthread −c −fno−strict−aliasing −DNDEBUG −g −O3 −Wall −Wstrict−prototypes
−I. −I./Include −DPy_BUILD_CORE −o Parser/grammar1.o Parser/grammar1.c
...
localhost:~/Python−2.3# make install
/usr/bin/install −c python /usr/local/bin/python2.3
...
localhost:~/Python−2.3# exit
logout
localhost:~$ which python
/usr/local/bin/python
localhost:~$ python
Python 2.3.1 (#2, Sep 24 2003, 11:39:14)
[GCC 3.3.2 20030908 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> [press Ctrl+D to get back to the command prompt]
localhost:~$

Sunday, March 27, 2011

Design pattern with Swing Actions

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JToolBar;

public class ActionSample extends JFrame {
 
 private Action sampleAction;
 private Action exitAction;
 
 public ActionSample(){
  super("Using Actions");
  
  sampleAction = new AbstractAction(){
   public void actionPerformed(ActionEvent event){
    JOptionPane.showMessageDialog(ActionSample.this, "The sampleAction was invoked!");
    
    exitAction.setEnabled(true);
   }
  };
  
  sampleAction.putValue(Action.NAME, "Sample Action");
  
  sampleAction.putValue(Action.SHORT_DESCRIPTION, "A Sample Action");
  
  sampleAction.putValue(Action.MNEMONIC_KEY, new Integer('s'));
  
  exitAction = new AbstractAction(){
   public void actionPerformed(ActionEvent event){
    JOptionPane.showMessageDialog(ActionSample.this, "The exitAction was invoked");
    
    System.exit(0);
   }
  };
 
  exitAction.putValue(Action.NAME, "Exit");
  
  exitAction.putValue(Action.SHORT_DESCRIPTION, "Exit Application");
  
  exitAction.putValue(Action.MNEMONIC_KEY, new Integer('x'));
  
  exitAction.setEnabled(false);
  
  JMenu fileMenu = new JMenu("File");
  
  fileMenu.add(sampleAction);
  fileMenu.add(exitAction);
  fileMenu.setMnemonic('F');
  
  JMenuBar menuBar = new JMenuBar();
  menuBar.add(fileMenu);
  setJMenuBar(menuBar);
  
  JToolBar toolBar = new JToolBar();
  
  toolBar.add(sampleAction);
  toolBar.add(exitAction);
  
  JButton sampleButton = new JButton();
  sampleButton.setAction(sampleAction);
  
  JButton exitButton = new JButton(exitAction);
  
  JPanel buttonPanel = new JPanel();
  
  buttonPanel.add(sampleButton);
  buttonPanel.add(exitButton);
  
  Container container = getContentPane();
  container.add(toolBar, BorderLayout.NORTH);
  container.add(buttonPanel, BorderLayout.CENTER);  
 }
 
 public static void main(String args[]){
  ActionSample sample  = new ActionSample();
  sample.setDefaultCloseOperation(EXIT_ON_CLOSE);
  sample.pack();
  sample.setVisible(true);
 }

}

Tuesday, March 22, 2011

Control mouse using the Robot Class

For these examples you will need to make sure you import the java.awt.Robot & java.awt.event.InputEvent classes.

Move the mouse cursor position on screen:


import java.awt.Robot;
 
public class MouseClass {
 
 public static void main(String[] args) throws Exception {
 
            Robot robot = new Robot();
 
            // SET THE MOUSE X Y POSITION
            robot.mouseMove(300, 550);
 
 }
}
--------------------------------------------------

Click the left mouse button:


import java.awt.Robot;
import java.awt.event.InputEvent;
 
public class MouseClass {
 
 public static void main(String[] args) throws Exception {
 
            Robot robot = new Robot();
 
            // LEFT CLICK
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
 
 }
}

--------------------------------------------------------------------------------

Click the right mouse button:

import java.awt.Robot;
import java.awt.event.InputEvent;
 
public class MouseClass {
 
 public static void main(String[] args) throws Exception {
 
            Robot robot = new Robot();
 
            // RIGHT CLICK
            robot.mousePress(InputEvent.BUTTON3_MASK);
            robot.mouseRelease(InputEvent.BUTTON3_MASK);
 
 }
}

--------------------------------------------------------------------

Click & scroll the mouse wheel:

import java.awt.Robot;
import java.awt.event.InputEvent;
 
public class MouseClass {
 
 public static void main(String[] args) throws Exception {
 
            Robot robot = new Robot();
 
            // MIDDLE WHEEL CLICK
            robot.mousePress(InputEvent.BUTTON3_DOWN_MASK);
            robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);
 
            // SCROLL THE MOUSE WHEEL
            robot.mouseWheel(-100);
 
 }
}

Log in to MySQL in Terminal

>>> mysql -u root -h localhost -p

ztron@ztron-desktop ~ $ mysql -u root -h localhost -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Monday, March 21, 2011

Reading and Displaying Text Files

import java.awt.*;
import java.awt.event.*;
import java.io.*;

@SuppressWarnings("serial")
public class isuru extends Frame implements ActionListener{
 String directory;
 TextArea textarea;
 
 public isuru(){
  this(null, null);
 }
 
 public isuru(String filename){
  this(null, filename);
 }
 
 public isuru(String directory, String filename){
  super();
  
  addWindowListener(new WindowAdapter(){
   public void windowClosing(WindowEvent e){
    dispose();
   }
  });
  
  textarea = new TextArea("", 24, 80);
  textarea.setFont(new Font("MonoSpaced", Font.PLAIN, 12));
  textarea.setEditable(false);
  this.add("Center", textarea);
  
  Panel p = new Panel();
  p.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 5));
  this.add(p, "South");
  
  Font font = new Font("SansSerif", Font.BOLD, 14);
  Button openfile = new Button("Open File");
  Button close = new Button("Close");
  openfile.addActionListener(this);
  openfile.setActionCommand("open");
  openfile.setFont(font);
  
  close.addActionListener(this);
  close.setActionCommand("close");
  close.setFont(font);
  p.add(openfile);
  p.add(close);
  
  this.pack();
  
  if(directory == null){
   File f;
   if((filename != null) && (f = new File(filename)).isAbsolute()){
    directory = f.getParent();
    filename = f.getName();
   }else{
    directory = System.getProperty("user.dir");
   }
   
   this.directory = directory;
   setFile(directory, filename);
  }
 }
 
 public void setFile(String directory, String filename){
  if((filename == null) || filename.length() == 0)
   return;
  File f;
  FileReader in = null;
  try{
   f = new File(directory, filename);
   in = new FileReader(f);
   char[] buffer = new char[4096];
   int len;
   textarea.setText("");
   while((len = in.read(buffer)) != -1){
    String s = new String(buffer,0,len);
    textarea.append(s);
   }
   this.setTitle("FileViewer: "+filename);
   textarea.setCaretPosition(0);
  }catch(IOException e){
   textarea.setText(e.getClass().getName()+ ": " + e.getMessage( ));
   this.setTitle("FileViewer: "+filename+ ": I/O Exception");
  }finally{
   try{
    if(in != null)
     in.close();
   }catch(IOException e){
   
   }
  }
 }
 
 public void actionPerformed(ActionEvent e){
  String cmd = e.getActionCommand();
  if(cmd.equals("open")){
   FileDialog f = new FileDialog(this, "Open File");
   f.setDirectory(directory);
   
   f.show();
   
   directory = f.getDirectory();
   setFile(directory, f.getFile());
   f.dispose();
  }
  else if(cmd.equals("close"))
   this.dispose();
 }
 
 public static void main(String args[]){
  Frame f = new isuru((args.length == 1)?args[0]:null);
  f.addWindowListener(new WindowAdapter(){
    public void windowClosed(WindowEvent e){
     System.exit(0);
    }
  });
  
  f.show();
 }

}

Sunday, March 20, 2011

File Copy by Java

import java.io.*;

public class isuru{

 public static void main(String args[]){
  if(args.length != 2){
   System.err.println("Usage: java File Copy");
  }else{
   try{
   copy(args[0], args[1]);
   }catch(IOException e){
    System.err.println(e.getMessage());
   }
  }
 }
 
 public static void copy(String from_name, String to_name) throws IOException {
 
  File from_file = new File(from_name);
  File to_file = new File(to_name);
  
  if(!from_file.exists())
   abort("No such source file: "+from_name);
  if(!from_file.isFile())
   abort("Can't copy directory: "+ from_name);
  if(!from_file.canRead())
   abort("Source file is unreadable"+from_name);
  
  //to_name
  if(!to_file.exists()){
   if(!to_file.canWrite()){
    abort("destination file is unwriteable: "+to_name);
   System.out.println("Overwrite existing file "+ to_file.getName()+"?(Y/N): ");
   System.out.flush();
   BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
   String response = in.readLine();
   if(!response.equals("Y") && !response.equals("y"))
    abort("existing file was not overwritten! ");
   
   }
  }else{
   String parent = to_file.getParent();
   if(parent == null)
    parent = System.getProperty("user.dir");
   File dir = new File(parent);
   if(!dir.exists())
    abort("destination directory doesn't exist: "+parent);
   if(dir.isFile())
    abort("destination is not a directory: "+parent);
   if(!dir.canWrite())
    abort("destination directory is unwritable "+parent);
  }
  
  FileInputStream from = null;
  FileOutputStream to = null;
  
  try{
   from = new FileInputStream(from_file);
   to = new FileOutputStream(to_file);
   byte[] buffer = new byte[4096];
   int bytes_read;
    while((bytes_read = from.read(buffer)) != -1)
    to.write(buffer,0, bytes_read);
  }finally{
   if(from != null) try {from.close();} catch(IOException e){;}
   if(to != null) try { to.close(); } catch(IOException e ){ ; }
  
  }
 
 }
 private static void abort(String msg) throws IOException {
  throw new IOException("FileCopy: "+msg);
 }

}

Delete File by Java

import java.io.*;

class isuru{
 public static void main(String args[]){
  if(args.length != 1){
   System.err.println("Usage: java Delete");
   System.exit(0);
  }try{
   delete(args[0]);
   System.out.println("Deleted successfully!");
  }catch(IllegalArgumentException e){
   System.err.println(e.getMessage());
  }
 }
 
 public static void delete(String fileName){
  File f = new File(fileName);
  if(!f.exists()) fail("Delete: no such file or Directory:"+fileName);
  if(!f.canWrite()) fail("Delete: write protected:"+fileName);
  
  if(f.isDirectory()){
   String[] files = f.list();
   if(files.length > 0){
    fail("Delete: directory not empty: "+fileName);
   }
  }
  
  boolean success = f.delete();
  
  if(!success) fail("Delete: deletion failed! ");
 }
 
 protected static void fail(String msg) throws IllegalArgumentException{
  throw new IllegalArgumentException(msg);
 }
}

Wednesday, March 2, 2011

Unix Basic Command

A

at : execute commands at a specified time/date.
awk: a scripting language, especially useful for manipulating text and automation.

B
bash : invokes the Bourne Again Shell (standard on most boxes).
batch: execute comands when load permits.
bc : interactive C-like calcultor (integers only).

C
cal : displays a calender, also lets you choose month/year using parameters.
calender : invoke a reminder service.
cancel : cancel request to calender.
cat : concatenate files (displays a file without scrolling ability. Simply dumps
it to the standard output. Can be useful when chaining multiple
applications to do complicated jobs, so one application can use another's
output as input).

cd : change the current working directory.
chgrp : change group ownership of a file.
chmod : change access patterns (permissions) to files.
chown : change user ownership of files.
clear : clear the screen.
cmp : compare two files.
cp : copy files.
cpio : archive and extract files.
cron : clock deamon (executes "batch" and "at" commands).
crontab : schedules commands at regular intervals.
crypt : encrypt , decrypt files using altered DES, standard to Unix passwords
(restricted distribution).
csh : invoke the C shell.
csplit : split file into several other files.
cu : call up another unix terminal.
cut : cut selected fields from each line of file.

D
date : displays the time and date (can also change it if you're root).
dd : convert and copy a file.
df : reports space (free, total etc') on all mounted file systems.
diff : copare two files.
diff3 : compare 3 or more files.
dircmp : compare two directories.
du : report disk usage.

E
echo : echo argument to standart output.
ed : line oriented editor.
egrep : extended version of grep (searches for extended regular expressions).
expr : evaluate boolean and arithmetic expression.

F
fgrep : same as grep, only it interprets patterns as a list of fixed strings.
false : return nonzero (false) exit status.
file : report type of file.
find : find matching files and run specified programs on them (optional).
finger : report user information (operates remotely only if a finger server is running
on the remote host).
ftp : (file transfer protocol) a client for FTP servers.

G
grep : search files for regular expression matches.

H
haltsys : gracefully shutdown sytem (can only be run by root. halt in Linux).
head : display first 10 lines of a file.

J
join : display the combination (lines with command field) of two fields.

K
kill : send a signal to terminate a process.
ksh : invoke the korn shell.

L
line : read a specific line out of a file (shell script usage).
ln : create a link to a file/directory.
logname : gets your login name.
lpr : sends a request to printer.
lprint : prints on local printer.
lpstat : reports printer status.
lpq : same as above.
ls : lists the contents of directory.

M
mail : send and recieve mail.
man : displays manual pages.
mesg : grant or deny permissions to recieve messages from other users using the
write command.
mkdir : create a new directory .
mknod : build a special file.
more : display file one page at a time.
mount : mount a storage device.
mv : move or rename a file.

N
news : display news item from NNTP servers.
nice : change priorities of processes.
nohup : run a command after logout (ignores hangup signals).
nroff : format files for printing.
nslookup : retrieve information from DNS servers.

O
od : displays a file in 8-based octals.

P
passwd : create or change login password.
paste : merge lines of files.
pr : format and print file.
ps : reports status of active processes.
pstat : report system status.
pwcheck : check /etc/passwd (default) file.
pwd : display current working directory.

R
rm : remove (erase) files or directories (unrecoverable).
rmdir : remove an empty directory.
rsh : invoke Restricted Bourne Shell.

S
sed : the stream editor.
set : assign value to variable.
setenv : assign value to enviroment variable.
sh : invoke Bourne shell.
sleep : suspend execution of a command for a given period.
sort : sort and merge files.
spell : find spelling errors.
split : split file to smaller files.
stty : set options for a terminal.
su : spawns a subshell with a different username, requires other user's
password,unless you're root.
sum : compute checksums and number of blocks for files.

T
tabs : set tabs on a terminal.
tail : display last 10 lines of file.
tar : a simple compression tool that merges multiple files into a single one,
originally made to make backing up materials on backup tapes easier.
tee : create a tee in a pipe.
telnet : access remote systems using the telnet protocol.
test : test various expressions and files.
time : display elapsed time (execution, process, and system times) for a
command.
touch : change time/date stamps of files.
tr : substitutes sets of charecters.
translate : translates files to different format.
troff : format files to phototypester.
true : return zero (true) exit status.
tset : set terminal mode.
tty : report a name of a terminal.

U
umask : set file-creation mode (permissions) mask.
umount : unmount a device.
uname : display the name of the current system.
uniq : report any duplicate line in a file.
units : convert numbers from one unit to another.
unzip : extract files from zip archieve.
uptime : report system activety.
uucp : copy files between two unix systems (oldie but still beautiful).
uulog : report uucp status.
uuname : list uucp sites known to this site.
uudecode : decode to binary after "uuencode" transmission.
uencode : encode binary file for email transmission.
uustat : report status of uucp or cancel a job.
uupick : receive public files sent bu uuto.
uuto : send files to another public Unix system.
uux : execute command to remote Unix system.

V
vi : a screen oriented (visual) editor (cool ,but Vim is better).

W
wall : sends message to all users (root only).
wait : await completion of background process.
wc : count lines, words, bytes etc' in one or more files.
who : report active users.
whois : search for user information.
write : send a message for another user (see mesg).
whoami : which user you are logged in as at the moment. If you, for example,
switch to a different user, logname will show the original username you
logged in as, and whoami will show the current user.


Z
zip : archieve file or files in zip format.

Monday, February 28, 2011

10 Things to do immediately after installing Ubuntu or XUbuntu 2011

1. Install Google Chrome

To install Google Chrome you can go to http://www.google.com/chrome and click Download Google Chrome Button and follow the downloading procedure.

or

Applications -> Ubuntu Software Center and Search for "Google Chrome" and you will get Google Chromium Web Browser as search result. Click "Install" to automatically get installed.

2. Install VLC

VLC player is the most downloaded and most distributions supported Video and Audio Player. And VLC supports many video and audio formats.

To download and install, open the terminal and write:

sudo apt-get install vlc

If terminal ask for a password type the root password. 
Note: When you write you will not see the password. 

3. Adobe Flash Player

To view most web pages online you must install Adobe Flash Player. Google Chrome has it's own Adobe Flash Player and you don't need to install Adobe Flash Player if you only use Google Chrome. But for Mozilla Firefox and other browsers you must install Adobe Flash Player.


To install, type in termianl:


sudo apt-get install flashplugin-nonfree

4. Install MPlayer.


Yet, another advanced but very simple video and audio player.


sudo apt-get install mplayer

and

sudo apt-get install w32codecs libdvdcss2

5.  Installing Unrar


sudo apt-get -y install unrar 

Friday, February 25, 2011

Django Basic Note

To create an application within a project, run the following command:

$ python manage.py startapp <app-name>

After writing a data model, the following command should be run to create the corresponding tables in the database:

$ python manage.py syncdb

To view the SQL queries generated by Django, issue the following command:

$ python manage.py sql <app-name>

Data models provide a variety of methods to interact with the database engine:

The objects.get method retrieves an object by a unique field
The objects.all method retrieves a list of all objects
The save method saves an object into the database
The delete method deletes an object from the database

To generate a Page not found (404) error, raise an exception of type Http404.




Thursday, February 17, 2011

Creating the main page view

A view in Django terminology is a regular Python function that responds to a page request by generating the corresponding page. To write our first Django view for the main page, we first need to create a Django application inside our project. You can think of an application as a container for views and data models. To create it, issue the following command within our django_working_directory folder:

$ python manage.py startapp <app_name>


After running this command, Django will create a folder named <app_name> inside the project folder with these three files:

• __init__.py: This file tells Python that <app_name> is a Python package
• views.py: This file will contain our views
• models.py: This file will contain our data models



Small Note On DJango

Django can be downloaded from the official Django website at
http://www.djangoproject.com/. Given that it is written in Python,
the same package works on all major operating systems.

To start a new Django project, issue the following command:
$ django-admin.py startproject <project-name>

To edit database information, edit settings.py of <project-name> folder.

To create database tables, issue the following command:
$ python manage.py syncdb


To start the development server, issue the following command:
$ python manage.py runserver


Django project settings are stored in the settings.py file. This file is a
regular Python source file that can be edited using any source code editor.
To change a variable, simply assign the desired value to it.

Wednesday, February 16, 2011

Installing Django on UNIX/Linux and Mac OS X

Installation instructions for all UNIX and Linux systems are the same. You need to run the following commands in the directory where the Django-x.xx.tar.gz archive is located. These commands will extract the archive and install Django for you:

$ tar xfz Django-x.xx.tar.gz
$ cd Django-x.xx
$ sudo python setup.py install

or in Debian Distributions,

$ sudo apt-get install python-django

You can test your installation by running this command:

$ django-admin.py --version

Wednesday, February 9, 2011

Ubuntu File User Access - PHP Programming

/var should stay chmod 755 and root:root. There is no reason to change /var.

For /var/www try:

chown -R myusername:www-data /var/www
chmod -R 755 /var/www
Make sure you keep this permissions when you create files. And you will probaby need to change some files to 775 on those that need to be written by apache2.

Important: Note that doing it this way, anybody who has access to your user account can modify the websites files.

Tuesday, February 8, 2011

.:Python Encryption and Storage:. | .:A Guide:.

Contents

  • Introduction
  • Encrypting
  • Storage
  • Making a *.pyc file
  • Single *.exe file
  • Closing
This is a guide to how to encrypt, or disguise, your text so people cannot read it, ways you can store information from a program for future use; and how to make your Python a single *.exe file.

There are many ways to hide data,

    * Encrypt the coding
    * Convert to a Python compiled file (*.pyc)
    * Convert to an *.exe file

Encrypting

The first is with the bz2 module. It comes native with Python, so you will not need any extra libraries. First you need to import it.
import bz2

Now, I will create a variable, and its contents will be the text I want to encrypt,

import bz2
x = raw_input("Enter Text To Encrypt:  ")

Now anything you enter in the raw_input will be stored in the local variable 'x'. The next bit of code does all the work. It encrypts your data and stores it into a variable.

import bz2
x = raw_input("Enter Text To Encrypt:  ")
y = bz2.compress(x)
That is it. Now the variable 'x' is encrypted and stored in the variable 'y'.

Here is an example. I will run this program and type 'Password' to be stored in the variable 'x'.




Now, you just need to make the text readable again. Use this code to decrypt it:

import bz2
x = raw_input("Enter Text To Encrypt:  ")
y = bz2.compress(x)
z= bz2.decompress(y)


Very simple. 4 Lines, and it can still be condensed if you need it to be!

There is one flaw in using this method, it is easily identified, as the encrypted text always begins with 'BZ'. Therefore, I have another method you can use.

This method works in quite the same way. You have to:

    * Import the module
    * Declare a variable that you want encrypted
    * Encrypt it

Here is the code for the second method:

import base64
x = raw_input("Enter Text To Encrypt:  ")
base64.b64encode(x)

Again, just 3 lines to encrypt it. Here is an example of how this one works:




As you can see, the text is not readable at all! Now to get it back to your text:
import base64
x = raw_input("Enter Text To Encrypt:  ")
y = base64.b64encode(x)
z = base64.b64decode(y)

4 lines. Very Very simple. If you do not just want to use 1, you CAN use both!

import base64, bz2
x = raw_input("Enter Text To Encrypt:  ")
y = base64.b64encode(x)
z = bz2.compress(x)
Now you can have a bit more security if you do not want your code released.


Storage


Many of you want to store information (or variables) from one program so another can use it later on. Well, the Pickle Module is great for that. It stores data in a way that only the Pickle Module can read. Pickle is great, but a faster version was created, cPickle. They work the same way, except that cPickle is fast. This module contains a faster reimplementation of the pickle module.

Here is how to load it:




import cPickle as pickle
If that does not work, you will have to use the native Pickle.





import pickle

Next, assign the text you want stored as a variable.

import cPickle as pickle
x = raw_input("Text you want stored:  ")


The next part may be a bit more complex than what you have read so far in this tutorial, so let me explain it,
    * The addition to the code above (see below) creates a new file, with the extension of *.p
    * It takes the variable 'x' and stores it in the file specified. If the file does not exist, it will be created in the current directory (unless specified otherwise).
    * The "w" means write. It will delete all contents of the *.p file specified and replace it with the information stored in variable 'x'. If you want to append data, use an "a" instead of "w".

import cPickle as pickle
x = raw_input("Text you want stored:  ")
pickle.dump(x, open("stored.p", "w"))
When you run this code, you will see the file 'stored.p' appear in the current directory. You will not be able to open it, it is used for pickle.
To read the information stored in the file, use the following code:
import cPickle as pickle
x = raw_input("Text you want stored:  ")
pickle.dump(x, open("stored.p", "w"))
y = pickle.load(open("stored.p"))
Note** I stored the loaded *.p file as 'y'.
This method is a great storage method. It is fast, and the *.p files cannot be read without pickle. It can also help to protect your code.
Making a *.pyc file
Many of you fear that if you leave your program as a *.py file, the source will be ripped, without credits. Well, another safety precaution is making it a *.pyc file. Automatically, a *.py file is created a a *.pyc the first time it is called upon (or imported).
So to create a *.pyc file, make a new file, and import the according *.py file you want converted to *.pyc.
Example:
I have a file, myCode.py, that I want as a *.pyc file. So I create a new file and type:
Save that file in the same directory as the *.py file you want converted.
Run it, and the program will now also be in *.pyc form!
Note** For those worried, you will still have the *.py file.
Also, you will have to delete the *.pyc everytime you want to update the *.py. You have to delete the *.pyc, close Python COMPLETELY. Then run it again with the updated features and it will make a new *.pyc. You will have to do this every time you update your program. Otherwise you will be like "I just fixed that! Why is it still doing the same thing?!" Single *.exe file ..............Tutorial on this available soon!

Monday, February 7, 2011

Executable Python Programs

$ chmod a+x helloworld.py
$ ./helloworld.py
Hello World
First, we have to give the program executable permission using the chmod command then run the source program.
The chmod command is used here to change the mode of the file by giving execute permission to all users of the system. Then, we execute the program directly by specifying the location of the source file. We use the ./ to indicate that the program is located in the current directory.

Sunday, February 6, 2011

Install tor in Ubuntu

Do not use the packages in Ubuntu's universe. They are unmaintained and out of date. That means you'll be missing stability and security fixes.

You'll need to set up our package repository before you can fetch Tor. First, you need to figure out the name of your distribution. A quick command to run is lsb_release -c. Here's a quick mapping:

Ubuntu 10.10 is "maverick"
Ubuntu 10.04 or Trisquel 4.0 is "lucid"
Ubuntu 9.10 or Trisquel 3.5 is "karmic"
Ubuntu 9.04 is "jaunty"
Ubuntu 8.10 is "intrepid"
Ubuntu 8.04 is "hardy"
Debian Etch is "etch"
Debian Lenny is "lenny"

Then add this line to your /etc/apt/sources.list file:
deb http://deb.torproject.org/torproject.org <DISTRIBUTION> main
where you put the codename of your distribution (i.e. etch, lenny, sid, maverick, lucid, karmic, jaunty, intrepid, hardy or whatever it is) in place of <DISTRIBUTION>.
Then add the gpg key used to sign the packages by running the following commands at your command prompt:

gpg --keyserver keys.gnupg.net --recv 886DDD89
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -

Now refresh your sources and install Tor by running the following commands (as root) at your command prompt:

apt-get update
apt-get install tor tor-geoipdb

To start:
make sure the tor and privoxy services have been started

sudo /etc/init.d/tor start
sudo /etc/init.d/privoxy start

Then start vidalia.....

Saturday, February 5, 2011

How to distribute your RAT/Trojan or Keylogger.

Mass Distribution
# Merge the server with another server put this up somewhere advertise for it.
# Create an iso with autorun.
# Create some cd's with autorun and leave them in random places.

Single Target 
You have a single target. Whether it be a cheating ex or a friend that screwed you or just some asshole you want revenge. Here's some interesting ways to go about this.
  • Send a binded exe that does something they want it to do. If they don't trust you infect a friend and a friend's friend etc until you have someone's msn aim yahoo or email that you can send it through that they'll accept.
  • Once again create an autorun cd give it to them have someone give it to them label it as their favorite band or maybe a movie they wanna see get creative. 
  • This is by far my funniest idea. Buy one of those shitty ipods or mp3 players off ebay the ones that are broken. Send it to them with an "installation cd" with your trojan on it. Trust me they'll fall for it.  

Making Undetectable Trojans By Ghosty

1. Encryptors/Compressors
You would think this should be the easiest way to UD (Undetect) a Trojan...but alas, it is not. The problem is simply this, most people use the same Trojans and Packers so often that Anti-Virus software knows pretty much all the signatures. They either use Ardamax Keylogger, Optix Pro, Beast, ProRat etc. for Trojans. For Packers they use UPX, PECompress, AsPack, Mophine etc. Again, none of these combinations work because all the signatures have been flagged. The best way this option will work is to find lesser known Packers and Trojans to work with.

Try a Google search for Executable Packers. Get a few that you have not heard of before or that have a decent rating. If it is not freeware, I am sure there will be a Crack for it. For Trojans, three good resources are VXChaos, LeetUpload or VX Heaven. Remember to pick the ones that are not well known and try to mix and match those Trojans and Packers.

2. Byte Adders:
This technique allows you to add junk bytes to your Trojan as to confuse Anti-Virus software. It does this by moving the code around inside the executable as the bytes are being added. This means that the signature will not be in the place the Anti-Virus expects it to be. A good tool for this would be StealthTools v2.0 by Gobo.

3.3. Hex Editing:
This is much more complicated and takes a lot more practice to get right. The idea here is to find the signature that Anti-Virus software has flagged inside of your Trojan and change it by adding a different byte, or changing the Offset to one of its other equivalents.The three things you will need here is a File Splitter, Hex Editor and a Anti-Virus Offset Finder. The File Splitter will cut your executable into smaller files (preferably 1 byte per file). You then use your Hex Editor on the file that holds the signature and change that signature. Or, you can keep the file complete and use your AV Offset Finder to find the Offsets automatically and just change the signatures found with your Hex Editor.

Step One: Place your Trojan Server in a folder.

Step Two: Split your Server with your File Splitter into 1 byte per file. This may make a lot of files in your folder (depending on how large the Server is), but it is worth it because you will know that only one or two of those files has the signature that is flagged and all the rest are clean.

Step Three: Scan your folder with your Anti-Virus software and make note of which files it says are infected. Those will be the ones you edit.

Step Four: Open up each infected file with your Hex Editor and change the Offset. There is no fool proof way of doing this, you will have to experiment. Since this will be a 1 byte file, there will not be much you need to change. Just change one character or byte at a time and then save your progress. Re-scan to see if it worked. If it did not, go back and try again.

Step Five: Once you feel that you have found all signatures and changed them, Rejoin your files with your File Splitter and test your Server to see if it works. Remember that too much Editing will make your Server useless so be careful.

(Optional) Step Six: Another good way is to use a Anti-Virus Offset Finder that will find the correct Offset automatically so you do not have to search for them or split your Server. Get AV Devil 2.1 to find the Offsets (password is: to0l-base).

You have to remember that different AV software use different signatures, so scan with as many as you can.

4. Source:
The very best way to make an undetectable Trojan has always been to make your own. I know it may seem like a daunting task to do, but it could be simpler then you think. Here I will give a few options on how to do this. The reason why you would want to make your own Trojan is the fact that each time it is compiled, it is given a new signature. Changing just a single string in the Source code can make it undetectable.

Option 1: Free Trojan Source Code.

Finding free Trojan source code is not hard. Again, going to places like VXChaos or Planet Source Code can yield a plethora of really good and lesser known Trojan code. Pick what Programming Language you like and look for examples. Not much needs to be changed to makes these undetectable. A simple recompile will sometimes do the trick.

Option 2: Decompiling.

Some may call this "Stealing" source code. I like to call it "Borrowing". The first thing you need to know is what language your Trojan is in. Lets say your Trojan was Optix Pro, your programming language would be Delphi. A good Delphi Decompiler would be DeDe. Decompile Optix Pro with DeDe then recompile it with a Delphi compiler and viola! Just change a few strings around within the source and you should have a undetectable Optix Pro.

Another way would be to open your Trojan with a Debugger or Disassembler. Copy down the ASM code and then recompile it in a ASM compiler. That maybe a bit more tricky, but the idea is the same. Try to convert the executable into pure ASM as best you can. There are many free Debuggers/Disassemblers, Google for them.

A word of warning, if you do find your own way of making a Trojan undetectable, DO NOT disclose it. You will find your Trojan detected in a very short amount of time. What I have taught here are just the basics of Trojan UDing. It will be up to you to use this knowledge and make it work. Also, DO NOT use any online virus scans to see if your Trojan has been detected. Your signature will be captured and sent to AV companies.

Well I hope this tutorial helped you out in some small way. Just one of the examples above could make an undetectable Trojan, or you may need to mix and match them. Try what you can, don't be afraid to experiment, and good luck!

VXChaos:
http://vxchaos.official.ws/

LeetUpload:
http://www.leetupload.com

VX Heaven:
http://vx.netlux.org

StealthTools v2.0:
http://www.hackerscenter.com/ (search for them)

AV Devil 2.1:
http://www.leetupload.com/dbindex2/index.php?dir=Win32/Crypters%20and%20Packers/&file=AV%20Devil%202.rar

Planet Source Code:
http://www.planet-source-code.com/

DeDe:
http://www.woodmann.com/crackz/Tools.html

Hide files in a jpg

Set up:
1. Must have a .zip or .rar compressor.

Steps:
1. Save the picture of choice to your desktop.
2. Make a new .rar or .zip folder on your desktop.
3. Add the files you want to hide into the .zip or .rar
4. Click start menu, run, cmd.
5. In Command Prompt type cd "desktop" with the quotation marks.
6. Now type in copy /b picturename.jpg + foldername.rar outputfilename.jpg
( If you use .zip then: copy /b picturename.jpg + foldername.zip outputfilename.jpg)
7. Now there should be the outputed file name with a .jpg extension on the desktop.
( Do not close Command Prompt just yet )
8. Double click it to open the picture and check it out.
9. When your done looking, and want to view the hidden files
Type: ren outputfilename.jpg outputfilename.rar or zip

How To Become A Hacker by Eric Steven Raymond

Read from here...Click here..

Friday, February 4, 2011

Turning a Hostname into an IP Address

#!/usr/bin/env python
#Get the IP Address

import socket
hostname = 'maps.google.com'
addr = socket.gethostbyname(hostname)
print 'The address of ', hostname, 'is', addr

Install VirtualEnv in Ubuntu

Once virtualenv is installed, you have the power to create any number of small, self-contained “virtual Python environments” where packages can be installed,
un-installed, and experimented with without contaminating your system-wide Python. When a particular project or experiment is over, you simply remove its virtual environment directory, and your system is clean. In this case, we want to create a virtual environment in which to test the googlemaps package. If you
have never installed virtualenv on your system before, visit this URL to download and install it:

http://pypi.python.org/pypi/virtualenv

Once you have virtualenv installed, you can create a new environment like this (on Windows, the directory containing the Python binary in the virtual environment will be named “Scripts” instead):

$ virtualenv --no-site-packages gmapenv
$ cd gmapenv
$ ls
bin/ include/ lib/
$ . bin/activate
$ python -c 'import googlemaps'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named googlemaps

As you can see, the googlemaps package is not yet available! To install it, use the pip command that is inside your virtualenv and that is now on your path thanks to the activate command that you ran:

$ pip install googlemaps
Downloading/unpacking googlemaps
Downloading googlemaps-1.0.2.tar.gz (60Kb): 60Kb downloaded
Running setup.py egg_info for package googlemaps
Installing collected packages: googlemaps
Running setup.py install for googlemaps
Successfully installed googlemaps
Cleaning up...

The python binary inside the virtualenv will now have the googlemaps package available:

$ python -c 'import googlemaps'

Now that you have the googlemaps package installed, you should be able to run the simple program named search1.py.

#!/usr/bin/env python
# Fetching a Longitude and Latitudefrom googlemaps import GoogleMaps
address = '207 N. Defiance St, Archbold, OH'
print GoogleMaps().address_to_latlng(address)
Running it at the command line, you should see a result like this:
$ python search1.py

(41.5228242, -84.3063479)



Credits goes to Foundations of Python Network Programming(Apress)

Wednesday, February 2, 2011

Short-notes for Linux

Exit GUI and start up again command line CTRL-ALT-BACKSPACE
Shift to command line CTRL-ALT-F1
Shift back to GUI CTRL-ALT-F7
Terminal window and enter the shutdown, halt, or reboot command, halt will log out and shut down your system.
Use CTRL-ALT-F7 to access the first session and CTRL-ALT-F8 for the second session.
To end your session, issue the logout or exit command. This returns you to the login prompt, and Linux waits for another user to log in.
Shut down the system $ shutdown -h now
Reboot CTRL+DEL+ALT
To create a link, hold both the CTRL and SHIFT keys while dragging the icon to the location where you want the link.
The startx command starts the GNOME desktop by default.
Terminal --- $ command-name options arguments
The ls command displays a listing of files in your directory.
CTRL-U erases the whole line and enables you to start over again at the prompt.

Saturday, January 29, 2011

Dragon Realm's Game

import random;
import time;

def displayIntro():
 print("You are in a land full of Dragons. In front of you!");
 print("You see two caves. In one cave the dragon is friendly...");
 print("and will share his treasure with you!");
 print("Other one is greedy and Kill you!");
 print();
 
def chooseCave():
 cave = "";
 while cave != "1" and cave != "2":
  print("Which cave will you go into?(1 or 2)");
  cave = input();
 return cave;
 

def checkCave(chosenCave):
 print("You approach the cave...");
 time.sleep(2);
 print("It is dark and spooky...");
 time.sleep(2);
 print("A large dragon jumps out in front of you and open the jaw...");
 print();
 time.sleep(2);
 
 friendlyCave = random.randint(1,2);
 
 if chosenCave == str(friendlyCave):
  print("Give you his treasure...");
 else:
  print("Gobbles you down in one bite...!");

playAgain = "yes";

while playAgain == "yes" or playAgain == "y":
 displayIntro();
 caveNumber = chooseCave();
 checkCave(caveNumber);
 print("Do you want to play again? y/n");
 playAgain = input();
http://inventwithpython.com/chapter6.html

Guess The Number Simple Game in Python

I am learning python at this moment and created simple game. I saw some tutorial before and just coded this.

#!/usr/bin/env python3.1
#This is a guess the number game.
import random;

guessesToken = 0;

print("Hello! What is your name?");
myName = input();

number = random.randint(1, 20);

print("Well, Myfriend "+myName+" let's play a game");
print("Guess a number between 1 and 20");

while guessesToken < 6:
 guess = input();
 guess = int(guess);
 
 guessesToken = guessesToken + 1;
 
 if guess < number:
  print("Your guess is too low!");
 if guess > number:
  print("Your guess is too high!");
 if guess == number:
  break;
if guess == number:
 guessesToken = str(guessesToken);
 print("You guessed it within "+guessesToken+" times congratulations!");

if guess != number:
 print("You failed man!");