Sunday, December 27, 2009

sflgtc - Seagate FreeAgent Led & Idle timeout Controller for Linux

Today, i got a Seagate FreeAgent external usb hd 500 GB. Since i was really bored, i made this little application that should be able to handle the Led and Idle Timeout on Linux as the windows software does. I dont know if there is something like this for linux, really, i didn't search..... but... hey... another one wont hurt!
Note that it's really dumb :).
To add new seagates devices, just add vendor_id & product_id on the structure, or send me the data and i'll do it.

Let me know, if something it's not working, or new usb commands should be added for a new device.

Good Luck Seagater's :)

Project: http://sflgtc.googlecode.com/
Download: http://sflgtc.googlecode.com/files/sflgtc.c

Test Device: 0bc2:3008 Seagate RSS LLC

Required: libusb-1.0

Notes:

Compile: gcc -o sflgtc sflgtc.c `pkg-config --cflags --libs libusb-1.0`
*
* Usage:
* ./sflgtc -l 0 -> Query Led State
* ./sflgtc -l 1 -> Switch Led On/Off
* ./sflgtc -t 0 -> Query current timeout set on device
* ./sflgtc -t -1 -> Disable timeout on device
* ./sflgtc -t seconds -> Set new timeout ( on win : 3 min, 5 min, 15 min, 1 hour, ... 5 hours its supported )
* ./sflgtc -l 0 -k -> ( Do not unload / load usb-storage module. You must remove it first, use this if you inteend to set led and timeout )
*

If you dont want the app to remove and reload usb-storage, use the "-k" option, but first:
# rmmod usb-storage
# use sflgtc with -k
# modprobe usb-storage

Sunday, September 20, 2009

Ekoparty 2009 Halted...

Ekoparty is improving each year, and the quality of the talks were better than ever.
Congratz to the organizers and friends, and as always, the next Ekoparty will always be the "hardest" to organize, since its really difficult to get better than it's each year.

On the first day, i went to almost all the talks. Particularly i liked the turbo talk of Bitmask Abussing and Binary Diffing.

On the second day, i only assisted to the SSL talk, but i fall sleep :(. I spent most of the time participating on the TippingPoint DRINC contest, until 4 pm, an unfortunatly event happened on the table where i was sitting and i stopped playing. i think that i got accepted 4 vulns for the contest, and 2 more that were not really exploitable, but they gave me drinks ticket for that two ( maybe because, i was starting to interrupt them to much :) ). I think that's the reason why i fall sleep on the auditorium on the ssl talk .

Next time, i will drink everything after the contest, and not while playing :P . The contest where well organized, but, sometimes, i really thought i was bothering the ppl at TippingPoint stand, since, they looked busy, and didn't know who was in charge of the contest to ask things. Also, next time, would be nice to write the ap password and ip address of the zdi on the board :)

Besides thats, the only bad thing at the ekoparty was the weather... i am getting a cold....

Tuesday, September 8, 2009

Finally, after some delay, acer & wmi will stop oops.
Patch was finally merged on linux-2.6.31-rc7-git5. http://patchwork.kernel.org/patch/29082/
The oops only happened when stack protector was enabled, and affecting only Acer Laptops .

Another patch relating kgdb + tty subsys, merged on 2.6.31-rc1 and core fixed by Alan Cox.
Info



Ekoparty comming soon.

Monday, July 13, 2009

Overheat = how dirty we are...

While looking for some "coolers pad" for the Acer, i came across this post http://www.insidemylaptop.com/clean-cooling-fan-acer-aspire-3003lm/ , and finally decided to clean the poor laptop.
After this, i got 40C less on power on. Current temp is 45 C, i was working on 95C.
I hope, i can compile a kernel without using the "Liliana" external fan anymore :)

Tuesday, May 26, 2009

Bored

since i got bored today, i updated an old proyect at http://github.com/lcostantino/rxwebcam/tree/master ( qt4 webcam viewer + example plugins )

Also , i added a test module for apache2 called iplimitrequest , just for fun at
http://code.google.com/p/modlimitiprequest/

gl

Saturday, October 18, 2008

New Sensor + Merge + FAQ [Tascorp 17a1:0128]

During the last months, Jean F. Moine did a lot of work to merge gspca inside the kernel mainstream. You can find gspca included in the kernel since 2.6.27.X. Also the libv4lconvert inclusion ( by Hans de Goede ) allowed to move decoding process from kernel space to user space, and hence , permitted a fast insertion of gspca in the main tree.

Also, libv4lconvert, allow compatibility between older apps ( using v4l1) and new formats conversion ( or specifics decoders that some apps do not include ) for apps that use v4l2.

In the last two days, a new sensor was added to the t613 subdriver ( which i
mantains). The new sensor is reported as OM6802. Thx to the people testing this ( Luiz Gonzaga da Mata, Marc Boettinger and Peter (from Austria ) ), also to J F Moine who developed big part of this sensor and fixes.

A new sensor have appeared too, reported 0x08 : 0x03, if anyone have this sensor, please mail me.

I also attach some little tools to extract image from UsbSnoop logs ( for tascorp / t613 only ) at the end.


So, always checkout the last hg from http://linuxtv.org/hg/~jfrancois/gspca/
if the current version is not working with your device.

[Little FAQ]

1) My webcam is not working, what i can i do?

1.1) Checkout lastest hg and test again. (libv4lconvert is inside v4l2-apps/lib/libv4l/ )

1.2) Check messages to find something relevant, like "sensor not found",
"not supported," usb error",etc.
1.3) Do a # echo 0x3f > /sys/modules/gspca_main/parameters/debug
1.4) Try svv application:
http://moinejf.free.fr/svv.c
1.4.1 ) ./svv
1.4.2 ) ./svv -r
1.4.3 ) ./svv -g -r ( image.dat sould be created if all goes ok )
1.4.4) If there is some "mode" error, you can also try ./svv -m r

1.5 ) Send all logs files within your email. Also attach the image.dat
if it was created on steps 1.4.x

1.6 ) Try to email the author of the subdriver fist and cc the involved people. If you dont get any response, you should email the current responsible of gspca ( moinejf@free.fr ). Also you can get in touch in the maillist.
If related to t613, mailme to lcostantino@gmail.com or le_costantino@pixartargentina.com.ar
1.7) Be prepared to test set of patches.

2) I got asked about win usb traces of my webcam, wtf?

2.1 Get http://www.pcausa.com/Utilities/UsbSnoop/default.htm
2.2 Start logging
2.3 Replug the webcam
2.4 Open the video capture application on win.
2.5 What i usually ask is the following for the first time:
1 - Start preview
2 - Stop preview
3 - Change resolution ( 640x480 -> 320x240 if vga, else another resolution )
4 - Do a Reset Defaults settings on controls
5 - Start Preview
6 - Stop Preview.
7 - Close the log file.
2.6 Attach C:\Windows\UsbSnoop.log.
2.7 Usually i dont care about the image frames ( isoch ), but its help to assure the format is the same as expected and we are not dealing with something else. ( anyway, this help for unknown bridges, etc ).
Do not keep long on the preview, or your log file will get really bigger.
2.8 If all goes ok, and you webcam start streaming when you test newer patches, then you could be asked by a new usb trace with differents instructions ( like changing gamma, colors, etc ).


3) Camorama, gcam, skype, etc, etc do not work!

3.0 Check you already have installed v4l1compat.so or v4l2convert.so
( /usr/src/gspca-xxxx/v4l2-apps/lib/libv4l )
Also there is a README inside that dir.

3.1 Camorama, GQCam and others apps are older. They still use v4l1. Thnxs to libv4lconvert you can still make use of this apps. Something like
#LD_PRELOAD=/usr/local/libv4l/v4l1compat.so camorama
could help.

3.2 Some applications, use v4l2 but do not support some format conversions, in that case you should need this ( for example ) :
#LD_PRELOAD=/usr/local/libv4l/v4l2conver.so skype
--------------------------------------------------------------------
Tools: Copy and Paste on each file.
The blog will mess all the formats, if you need it let me know, i will send it via email. ( one day i will upload it on some place )
This tool is just for analysis purposed, but if you wanna play, is just a simple parser. Also the code could be reduced to fewer lines, but i don't care, its for my use.

How to use it:
1) ruby extract_sets.rb UsbSnoop.log outdir/
2) ruby extract_image.rb outdir/
Extracting from outdir/
Total: 462 Processed: [5/462] [1%]
3) You should see .dat and jpg files inside outdir.

========================================================================
[BEGIN extract_set.rb ]

#!/usr/bin/ruby


if ARGV.length < 2 || ARGV[0].empty? || ARGV[1].empty?
print "Tascorp Image Extract\n"
print "./extract_sets.rb [usbsnoop log file] [sets_dir]"
print "\n"
exit 0
end

print "Extracting from #{ARGV[0]} to Ouput dir #{ARGV[1]}\n"

begin
archivo = File.new(ARGV[0],"r")
rescue => err
puts "Error: #{err}"
exit 0
end

begin
Dir.open(ARGV[1])
rescue => err
puts "Dir do not exists... creating it..."
begin
Dir.mkdir(ARGV[1])
rescue => mkdir_err
puts "Error on mkdir #{err}"
exit 0
end

end

start = false

out_set = nil
count = 0
while str = archivo.gets
if str.strip.chomp.match('[0-9a-b]+:')

if str =~ /ff d8/
start = true
out_set = File.new("#{ARGV[1]}/#{count}.dat","w")
puts "Extracting set #{count}"
count+=1
elsif str =~ /ff d9/ && start == true

out_set << str
out_set.close
start = false
end
if start == true
out_set << str
end
end

end
[ EOF extract_sets.rb ]

[ BEGIN extract_image.rb]

#!/usr/bin/ruby

if ARGV.length < 1 || ARGV[0].empty?
puts "./extract_image.rb data_set_dir"
exit 0
end

print "Extracting from #{ARGV[0]}\n"

count = 0
Dir.chdir(ARGV[0])

files = Dir.glob("*.dat").sort

files.each { |fname|

archivo = File.open(fname)
final_data = String.new
data = Array.new
count += 1
str = "Total: #{files.count} Processed: [#{count}/#{files.count}] [" +
((count*100)/files.count).to_s + "%]"

str.length.times { print "\b"}
print str
$stdout.flush


while str = archivo.gets

nset =
str.strip.chomp.gsub(/[0-9a-h]+:/,'').strip.gsub(/([A-Z]|\[|-).*/,'').gsub(/^02 a[0-1]/,'').strip

if ! nset.empty?
nset.split(' ').each { |s| data << s}
end
end
out = File.open("#{fname.sub(".dat",".jpg")}","wb")
data.each do |byte|
out.print byte.to_a.pack("H*")
end
out.close
}

puts "done"

[EOF extract_image.rb]