Friday, June 8, 2012

How To fsck a Truecrypt Volume (solution)

In Linux, unencrypting a truecrypt volume as "unmounted" will create a temporary file like this
/tmp/.truecrypt_aux_mnt1/volume



Recently when trying to run fsck or e2fsck on a corrupted truecrypt volume, I was presented with this
# fsck.ext4 -p /tmp/.truecrypt_aux_mnt1/volume
/tmp/.truecrypt_aux_mnt1/volume: recovering journal
fsck.ext4: unable to set superblock flags on /tmp/.truecrypt_aux_mnt1/volume


/tmp/.truecrypt_aux_mnt1/volume: ********** WARNING: Filesystem still has errors **********




Most websites will tell you to recover using a separate super block, but that is likely not the problem here. The problem is that fsck.ext4 can't properly fix an ext4 image file directly. The file must be mounted with losetup, and then it can be checked properly.
# losetup -f /tmp/.truecrypt_aux_mnt1/volume
# fsck.ext4 /dev/loop0e2fsck 1.42 (29-Nov-2011)
/dev/loop0: recovering journal
Setting free inodes count to 15549549 (was 15549553)
Setting free blocks count to 19290620 (was 19290665)



After mounting the image to a loopback device you can see that fsck was successful. To unmount the image from the loopback device, run
# losetup -d /dev/loop0



encrypted mounting ubuntu


Comment or leave feedback sepero 111 @ gmx . com

Wednesday, May 2, 2012

Webmasters- Don't Neglect Visitor Feedback

Today I will remark on a very common issue, neglecting visitor feedback. If you want the largest amount of great feedback, this is my advice-

Allow visitors to give textual feedback directly on the page they are currently on, and have it displayed on that page for others to see.

God forbid that visitors correct (or suggest corrections to):
  • Typos
  • Grammar
  • Broken links
  • Incorrect information
  • Outdated information
  • Page order, organization


There are different ways to allow visitor feedback:
  • wiki page implementation (should always include a separate "talk" page for every informational page)
  • visitor comments on page, and visible to others
  • a url to a contact page, email, mailing-list, or forum

Note:
The only intelligent reason I can think of making visitor feedback difficult is if your content is highly controversial, or "politically incorrect". You will surely become vandalized often if that is the case.



Wiki

When should you use wiki implementation?
  • Whenever information changes over time.
  • Whenever it's possible that the information could be more complete.


Recognize that vandalization will always occur with wiki style pages, but the positives can often out weigh the negatives. Is your content more likely to be vandalized than the average website? These are all pretty subjective criteria, so you just have to make an estimation of your own level here.

A wiki implementation allows visitors to easily fill in gaps of information. Wiki can also lead to visitors making tiny edits/corrections here and there- innovative little ideas about writing things that would have never crossed your mind.

Wikipedia.com has moderators, registered users, and even allows for some anonymous user editing. They are an excellent example of how to implement wiki style editing.




Comments

When should you use page comments?
  • Anytime you're not implementing wiki.

Yes, you read that right. Simply put, if it's not a wiki type page, you should implement visitors comments. Why the hell wouldn't you? If you don't allow comments because you are trying to avoid spam, think again. The amount of spam you receive will be proportional to amount of quality feedback you get. If you exclude comments to reduce spam, you're successfully reducing quality feedback also.

Many people like to read the comments of others and this can also keep visitors on your site longer. Visitor comments can sometimes reveal tremendously informative things that were not mentioned by the page author. Also, having other visitor comments displayed will encourage new visitors to be less shy about giving their input on the page.


How to handle comments-
Use common sense. You want comments to be super easy, while also reducing spambots. An excellent solution to this problem is OpenID login. People can still remain semi-anonymous, while still being scrutinized on an identity basis. The barrier to leave feedback is very low, while amount of spam protection is just as high as if you had gotten their credentials directly. On a website I previously ran, I permitted anonymous comments, and I setup filters to moderate comments that posted url links (likely spam). Also comments were blocked based on a honeypot input system. The filters would automatically block and remove any repeat offenders. This successfully allowed anyone to comment, while having virtually no spam.



Contact Page, Email, Mailing-list, or Forum


These are all good forms of contact, but none are an intelligent replacement for wiki or on page comments! These forms of feedback should be thought of as complimentary. They require more initial time, preparation, and knowledge from from the user. They also may require the user to reveal more information than they may be willing to divulge (therefore preventing them from giving feedback at all).

These forms of contact act to compliment a good feedback system, but often are poor if used alone.





Conclusion

Every website is going to have different needs, but we create all this content for the visitors. If we are doing something wrong, we should be smart enough to allow those visitors to let us know.

Friday, April 27, 2012

Binary Grep Program: SearchBin

SearchBin is a fast commandline program for searching within binary files. It's a bit like grep for binaries.

It has three capabilities for searching.
-Search for bytes using hexidecimal
-Search for a plain text string
-Search for a smaller binary file


EXAMPLES
Search for the hex bytes "FF14DE" in the file gamefile.db:
$ ./searchbin.py -p "FF14DE" gamefile.db
Match at offset:            907          38B in  gamefile.db
Match at offset:           1881          759 in  gamefile.db
Match at offset:           7284         1C74 in  gamefile.db
Match at offset:           7420         1CFC in  gamefile.db
Match at offset:           8096         1FA0 in  gamefile.db
The printed offsets are listed in decimal and hex formats.


You can also search for unknown patterns with "??". Just insert them where ever you have an unknown byte:
$ ./searchbin.py -p "FF??DE" gamefile.db

You can search through multiple files at once, and search piped input:
$ ./searchbin.py -p "FF??EE" gamefile.db supersecret.idx
$ cat gamefile.db | ./searchbin -p "0xFF??EE"

You can also search using regular text strings and other binary files.
$ ./searchbin.py -t "hello" gamefile.db
./searchbin.py -f binaryfile gamefile.db 



Options of SearchBin:

$ ./searchbin.py --help

Optional Arguments:
  -h, --help            show help message and exit
  -f FILE, --file FILE  file to read search pattern from
  -t PATTERN, --text PATTERN
                        a (non-unicode case-sensitive) text string to search
                        for
  -p PATTERN, --pattern PATTERN
                        a hexidecimal pattern in format '0xFF'
  -b NUM, --buffer-size NUM
                        read buffer size (in bytes). 8MB default
  -s NUM, --start NUM   starting position in file to begin searching
  -e NUM, --end NUM     end search at this position, measuring from beginning
                        of file
  -m NUM, --max-count NUM
                        maximum number of matches to find
  -l FILE, --log FILE   write matched offsets to FILE, instead of standard
                        output
  -v, --verbose         verbose, output the number of bytes searched after
                        each buffer read
  -V, --version         print version information




Extra Notes:
An argument -t or -p or -f is required. The -p argument accepts a
hexidecimal pattern string and allows for missing characters,
such as 'FF??FF'. When using -f argument, the pattern file will
be read as a binary file (not hex strings). If no search files are
specified, %prog will read from standard input. The minimum memory
required is about 3 times the size of the pattern byte length.
Increasing buffer-size will increase program search speed for
large search files. All size arguments (-b -s -e) are read in decimal
format, for example: '-s 1024' will start searching after 1kilobyte.
Pattern files do not allow for wildcard matching.
Reported matches are displayed as 0-based offset.


Further Examples:
Search for the text string "Tom" in myfile.exe. Text is case sensitive.
./searchbin.py -t "Tom" myfile.exe

Search for the text string "T?m" in myfile.exe, where ? is a wildcard. This will match "Tom" "Tim" "Twm" and all other variations, including non-printing bytes.
./searchbin.py -t "T?m" myfile.exe

Search for the hexidecimal pattern "AABBCCDDEE" in myfile.exe.
./searchbin.py -p "AABBCCDDEE myfile.exe

Searches for the hexidecimal pattern "AA??CC??EE" in myfile.exe, where ?? can be any byte value.
./searchbin.py -p "AA??CC??EE" myfile.exe

Takes the binary file pattern.bin, and searches for an exact match within myfile.exe.
./searchbin.py -f pattern.bin myfile.exe





Features:
+No compiling necessary
+Requires Python 2.7 or Python 3
+Less code
+Search in files of unlimited size
keywords: hex hexidecimal binary like grep search seek find fast



DOWNLOAD it from here:
https://github.com/Sepero/SearchBin/archive/master.zip

Source:
https://github.com/Sepero/SearchBin

Report Problems, Suggestions, or Thanks to sepero 111 @ gmx . com
  or https://github.com/Sepero/SearchBin/issues




2012 Jun 19 Update:
Major over haul to search function. Dramatically increased search speed for wildcard patterns. Also included search functionality for regular text strings.

2012 Jun 28 Update:
Made updates to Readme file and added more comments to code for readability.
Also, I moved all files to Mercurial and bitbucket.com.

2012 Jul 07 Update:
Unifying all documentation. Publishing to freecode.com

2013 Feb 02 Update:
Switched code indentation to tabs as it is a universal standard. Moved code back to github due to its popularirty.

2013 Oct 11 Update:
Added Python 3 support. Added in more unittests. Added in more information code comments. Updated documentation.