Tag Archives: linux

LVM: reduce partition size

# umount mountpoint with lvm partition
unmount /data

# check for errors and fix them
fsck -f /dev/sys/data

# resize filesystem to 80Gb
resize2fs /dev/sys/data 80G

# deactivate logical volume
lvchange -an /dev/sys/data

# change size of logical volume
lvreduce --size 191G /dev/sys/data

# create new volume «drbdmaster» in logical group «sys» with size 4Gb
lvcreate -n drbdmaster -L4G sys

# activate volumes
lvchange -ay  /dev/sys/data
lvchange -ay /dev/sys/drbdmaster

# mount data
mount /dev/sys/data

# create filesystem on drbdmaster
mkfs.ext4 /dev/sys/drbdmaster

# mount drbdmaster
mkdir -p /drbd/master
mount /dev/sys/drbdmaster /drbd/master

repack initrd

unpack:
file initrd
gzip compressed data, from Unix, last modified: Tue Mar 11 10:56:38 2014, max compression
mv initrd initrd.gz
gunzip initrd.gz

Now we got initrd file, which is cpio archive, unpack it:
cpio -id < initrd

and you could do with it what do you want,

after that we have to pack it again
find ./ |cpio -H newc -o > /tmp/initrd.cpio
gzip < /tmp/initrd.cpio > /tmp/initrd

and we got new initrd !

IT Security Brothers (http://itsb.pro)

Hi guys, I would like to present you our new project IT Security Brothers http://itsb.pro
We provide pentest, consultations and IT outsourcing services.
Feel free to hire us for IT jobs.

Subversion client: wrong default permissions

Default permissions on the folder with plaintext passwords from SVN:

ls -la /home/alter/.subversion/auth/svn.simple

drwxrwxr-x. 2 alter alter 4096 нояб. 7 16:44 .
drwxrwxr-x. 6 alter alter 4096 июня 14 2011 ...
-rw-r--r-- . 1 alter alter 144 июля 18 2011 28c62da73b202226d356b9ab8f841daa
-rw-rw-r-- . 1 alter alter 141 нояб. 7 16:44 292a2b271c421acc9002974b69090349
-rw-r--r-- . 1 alter alter 144 июля 19 2011 7ece931cd5b8565388b0ae20754c3215
-rw-r--r-- . 1 alter alter 132 июля 5 2011 c752ec77a7ea7af3a13b7116f986bd95

It's a holy shit !!

chmod -R 0600 /home/alter/.subversion/auth/
chmod -R +X /home/alter/.subversion/auth/

ls -la /home/alter/.subversion/auth/svn.simple

drwx--x--x. 2 alter alter 4096 нояб. 7 16:44 .
drwx--x--x. 6 alter alter 4096 июня 14 2011 ...
-rw------- . 1 alter alter 144 июля 18 2011 28c62da73b202226d356b9ab8f841daa
-rw------- . 1 alter alter 141 нояб. 7 16:44 292a2b271c421acc9002974b69090349
-rw------- . 1 alter alter 144 июля 19 2011 7ece931cd5b8565388b0ae20754c3215
-rw------- . 1 alter alter 132 июля 5 2011 c752ec77a7ea7af3a13b7116f986bd95

Restoring files under linux

Find packet of utilites to restoring named
app-forensics/sleuthkit
and install it.

For UBUNTU and others plase find it manually like apt-get search sleuthkit.

The next you can find files. Type 
fls -rd /dev/sda1

To restore files you can do:
for i in $(fls -rd /dev/sda1 |awk {'print $3'}|tr -d [:]); do icat -r -f ext /dev/sda1 $i > /home/yuri/photo/$i.jpg;done

Hear is supported file systems:
icat -f list

dir-320 + dd-wrt + gcc (compiling under dir-320)

We go on dd-wrt.com. In section download firmware for dir-320 – dd-wrt.v24_usb_generic.bin (latest v24).

It is required console tftp, it is possible to establish through the manager of installation of standard applications in windows, as and in linux.

We keep in some folder under a name firmware.bin. We open the console №1, we pass in a folder where  firmware.bin, we make a command «tftp 192.168.0.1 ″, we prepare a command« put firmware.bin»

We open the second console, we write and it is started «ping-f 192.168.0.1 ″ (for linux)« ping 192.168.0.1-n 1000 ″ (for win). ICMP the answer shouldn't come back, if, of course, at a router ip not 192.168.0.1.

We switch off a router power, then turn on it. It is necessary to seize that moment when there will be answers from a router in the second console. During this moment it is necessary to start in advance prepared command in the first console.

If all has passed successfully there will be a message in the first console that the firmware is successfully loaded. Otherwise we repeat above written.

It is necessary to wait burning of a light-emitting diode «status», or occurrences of a wireless network «dd-wrt» that signals that the router is booting with new firmeware successfully!

As a result we receive a router with an firmeware dd-wrt.

For the next we will need in flash drive with ext2fs. It is possible to format in any way. An example for linux Ubuntu.

# mkfs.ext2/dev/sdb1

As a result it is received flash drive with section ext2fs.

We insert it in USB router port.

We correct router options through web. Under the standard now at router IP will be 192.168.1.1. In an address line of the browser we write 192.168.1.1.  Login/pass – admin/admin. Further Services-> USB. To include points on «Base support USB","Support USB 1.1 (OHCI)","Support of USB-disks","Support file.system ext2/ext3 ″,« Automatic Drive Mount », others to disconnect. Assembling point«/opt». Further button" Apply ". The router reboots.

Further a tab «servicing» (penultimate). It is necessary to include «Support JFFS2. As we press point to apply. The router reboots.

Now it is necessary to come a telnet on a router.

# telnet 192.168.1.1

login/pass – root/admin.

Whether now it is necessary to check up mounted a flash drive.

# mount

If there is a point/dev/discs/disc0/part1 on/opt type ext2 (rw), means mounted.

Further we mount a folder jffs.

# mkdir/opt/jffs/

# mount-o bind/opt/jffs//jffs/

All. The system is ready to installation!!

We put optware.

# wget-O/tmp/prep_optware http://wd.mirmana.com/prep_optware

# sh/tmp/prep_optware

Process long. We wait.

We load/is updated a tree of packages.
# ipkg-opt update

We put buildroot.
# ipkg install buildroot
Process as the long.

We export enviroments the necessary.
# export LD_LIBRARY_PATH =/opt/lib: $ LD_LIBRARY_PATH

All. Now it is possible to compile the programs on C.

#gcc <input file>-o <outputfile>