1st October, 2009

Synchronizing folders between Linux & Windows using unison /--evilbitz   

Hi there,

Here is a common case, you have a linux webserver and you want to update all the files, you probably work locally on the files and want to send th update to the server without the trouble of manually selecting the files and upload them via FTP.

We’ll use unison for this task and we’ll send the files over an ssh connection. Unison works very similar to rsync but is really easier for use. My Linux server runs on Debian.

Setting up the server (Linux)

  1. apt-get install unison
    This will install the latest stable version of unison for debian, you can use yum if you’re using a Red Hat flavour of Linux.
  2. apt-get install ssh
    If it’s not already there ;)  

Setting up the client (Windows)

  1. Install the text version of unison for Windows, make sure you’re getting the same version as you installed on your server – it wouldn’t work otherwise!
    Useful links: Download Page, Unison for windows – Version 2.27
    Copy the unison-text.exe file to c:\windows\unison.exe
  2. Install ssh client, download OpenSSH for windows and install the client.

Performing a sync

Let’s say you want to synchronize C:\www with /home/guy/www, you’ll have to execute the followin command (go to windows cmd):
C:\> unison www ssh://guy@webserver-ip//home/guy/www

This will synchronize all files between both directories, it will ask you for an action, you can include files or ignore them, just type ? and press enter to see all available options. Ok, what if you want to ignore a certain directory, which contains all kinds of sources for graphic files for instance… you can just include the -ignore switch, like this:
C:\> unison -ignore “Path sources” ssh://guy@webserver-ip//home/guy/www

In case you know you are doing a one way sync and you don’t want to be asked for too many questions, you may go with:
C:\> unison -silent -ignore “Path sources” ssh://guy@webserver-ip//home/guy/www

Making a mirror

This is really what fits best to our scenario, the files are on a windows machine will be the source of our mirror and the webserver directory the mirror itself:

C:\> unison c:\www ssh://guy@webserver-ip//home/guy/www -force c:\www -auto

The last command tells unison to force a mirror when c:\www is the source, and the destination address is /home/guy/www

Final word

Well, that’s it… simple, isn’t it? ;)
In case you have questions, you can comment below…

Thanks,
Guy.



Posted in linux | Be The First To Comment!

19th September, 2009

Accidently deleted your partition table? /--evilbitz   

In this post you can get some hints on what to do in case you accidently ruined your partition table, for example, you deleted one of your volumes (drive letters) and you cannot see it.

First of all, I want to start with a warning… doing this stuff to your hard disk may gets you to a point of frustration, losing all your data and getting the middle finger from the kind and beloved mr. samsung/WD/whatever/(made in China). I’m not gonna describe how to backup your hard drive, I assume you know that :)

The number one rule is to never try to edit or change anything from the Windows Disk Management tool, it’s crap. Most chances it is the reason for you ending  up on this page :)

Here are some information about the data structures that are used to manage your boot partitions, I’m not going in-depth here but rather just describing some basic things that are good to know. If you want, you can skip this section. Lets start with the MBR (Master Boot Record). The MBR contains a small piece of code at its begining, your BIOS loads it into memory and then exeute it in real mode. Anyways, the MBR basically just manages the entries in the partition table. Part of the MBR (at offset 0×1BE) is the partition table itself, there you have 4 entries to 4 Primary partitions on your disk, where each one can be defined at Extended and point to a number of Logical partitions (which used to be non-bootable, but today boot loaders handles them fine).

  • Primary – bootable partition
  • Extended – Pointer to a number of logical partitions
  • Logical – data partitions, intended to be non bootable

I would recommend reading more about this right here.

Here are some tools that you want to know:

  • TestDisk – this is a really good tool that can analyze every sector of your hard drive and find lost volumes, then it lets you edit the partition table and write it to disk.
  • Acronis Disk Director – good partition manager with disk editing capabilities, this is good if you want to investigate your sectors closely and see the data structures.

There are tons of other tools, I’m using these ones and they are great! I wouldn’t recommend hiren boot cd which has all these tools and more preinstalled and configured.

Ok, so here is the flow for reconstructing the partition table with TestDisk, and maybe add fixups using Windows bootrec.exe if you are running Vista.

  1. Execute TestDisk and let it analyze your disk, if it didn’t found exactly the partitions you are looking for, perform a deeper search. When you get the results all of the partitions are marked DELETED, you should turn the wanted partitions to Primary and Logical, the partition you used to boot into should be set to Primary Bootable.
  2. When you are ready, the partition table appears in a neat green color, telling you everything is ok. Write the partition table to disk.
  3. Try to boot the hard drive, if it fails, you may want to look at Super Grub and maybe later on, install to disk. Super Grub is a really handy boot loader that you can execute without installing to disk. It lets you boot from any partition. I’m not going to cover how to use Grub, try looking for info if you need this.
  4. If you are a windows user, insert the installation disk of windows vista, or download the neosmart recovery custom Vista disc, when the disc loads go to ‘Recovery’, and open a command prompt. Execute these commands:bootrec /fixmbr
    bootrec /fixboot
    bootrec /rebuildbcd

    See the output and confirm

  5. Load your operating system.

In case you want to hide some partitions, like the recovery partition of your laptop, you can user Acronis boot director.

Well that’s about it… even if this post doesn’t speak to you, just remember, never use the Windows Disk Management console :)

Thanks,
Guy.



Posted in random | Be The First To Comment!

18th September, 2009

Proposal of efficiency: mouse selection /--evilbitz   

Sometimes selecting text with the mouse can be troublesome, it could have been nice if you could fix your selection by adding or removing parts of the text.

Photoshop has made this nice, where by choosing the selection tool and holding down the the ALT or SHIFT keys you can add or remove pixels to or from your selection.

I wish this were built-in in the operating system, so you could easily fix your selection of text if you got it wrong.



Posted in random | Be The First To Comment!

18th November, 2008

Windows live messenger impersonation /--eitama   

Comes a time, when you wish you knew what goes in that twisted head of your best friend/worst enemy.
These people are often in your windows live messenger contact list, among their friends and relatives.

When a new message pops up from your best bud in the windows taskbar,
you don’t see much details it usually looks like “Dany – Conversa…” not much to think about besides – Dany wants to chat (:

So you open the new message window and chat away,
little that you know, it actually not Dany!

In messenger, this is so easy to achieve, you just change your :
(None require registration, and are all immediately updated)

  • Display name (The name that appears in the contact list)
  • Personal message (The message people see next to your display name in the contact list)
  • Display picture (Just print screen and cut it from the victim’s display picture)
  • Fonts and colors (Easy to obtain, not so easy to identify)

This is usually more then enough to fool the next guy.

Let’s say A B & C are all friends and have each other in their contact lists,
A Changes his own details to look like B, and sends C a message : “Hey man, What you think about A????”
C, Having harsh and repressed feeling for A, uses the chance to say everything he was hoping to say about A, to B, But B is A!!!
Be careful about what you do with this,
from my experience, it works every time, but i have only used it to trick friends and create funny events.

The only way your victim could know something is wrong is to see that he has TWO ‘B’s online at the same time,
or to check out B’s e-mail address, but people never check these things.

(Results of misuse of this trick are your responsibility and you are taking your own risks…)

Cheers,



Posted in random | Be The First To Comment!

12th October, 2008

Simple trick if you are dealing with lots of log files /--evilbitz   

Well, it’s all about the numbering :-)

You start with 1.txt and ends up with 1756.txt, too many logs and they always seems unorganized on your disk, so you are arranging the file by date but this may also be a problem with asyncronous writing to log files. And either way, it still it look bad when you arrange the files by date.

So do what I do, start numbering your files from 10000, this way they’ll be arganized by their name properly.

This is silly I know :-)



Posted in programming, random | 1 Comment

Top »
"If you can't join them, beat them!"
Search Evilbitz: