יום שני, 7 במרץ 2011

Maxwell MXI to PNG automation script

I've been experimenting with the console of Maxwell once and found this script to automate generation of 8 bit PNG's, it's not the best script ever but perhaps it could help someone that wants an automated
// Script start: 

// variable definitions- Zstart is the first frame, Zstop is the last frame
var Zstart = 0 ;
var Zstop = 2500 ;

//
var Znum = "000";
// Znum is a filename organizer helper 
var zi = Zstart ;
for (zi=Zstart ; zi < Zstop+1 ; zi++ )
{
if (zi < 10) {Znum = "000"};
if (zi > 9 && zi < 100) {Znum = "00"};
if (zi > 99 && zi < 1000) {Znum = "0"};
if (zi > 999 ) {Znum = ""};
var Zok = "basefilename" +Znum + zi;
var ZokFile = (Zok + ".mxi");
var ZokOut = (Zok + ".png");
Maxwell.openMxi("C:\INPUTMXIPATH\" + ZokFile );
Maxwell.saveImage("C:\OUTPUTMXIPATH\"+ ZokOut , 8);
};

// Script End
BOLD items are the ones you should edit prior to execution.

note: If you desire a Jpeg output, Please replace the ".png" with ".jpg"
comments are most welcome !Zok.

יום ראשון, 6 במרץ 2011

Keylogger for a special project using microsoft powershell

In one project we have to take input of 4 sattelite dishes and decide if the signal is lost. the outcome must be some kind of graph that could show when, where and what device has lost connection, this will help us to learn when a signal was lost and perhaps also in what conditions.
first thing we've done is open a USB keyboard we had and get it's USB controller.

we have 4 input devices so we've decided to use the keyboard numbers 1-4 , each signal will be connected to a certain keyboard input and then we could log it's status once each 100ms.

after searching over the net finding nothing but spam, Mr. Braitmaiere, A family member that has a large mind, has developed this code for us to use in Microsoft PowerShell:



/// Start Code:
$signature = @'
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern short GetKeyState(int virtualKeyCode);
'@
$getKeyState = Add-Type –memberDefinition $signature -name “Win32GetKeyState” -namespace Win32Functions –passThru
$charCheck = @([char]'1', [char]'2', [char]'3', [char]'4')
while ($true)
{
Start-Sleep -Milliseconds 100
$logged = ""
foreach ($char in $charCheck)
{
$vkey = [int]$char
$result = $getKeyState::GetKeyState($vkey)
$result = 0x8000 -band $result
if ($result -ne 0)
{
$logged += " 1 "
}
else
{
$logged += " 0 "
}
}
$now = Get-Date;
$logLine = "signals $logged @ " + $now.ToUniversalTime().ToString("dd/MM/yyyy HH:mm:ss:fff")
$fileName = $now.ToUniversalTime().ToString("yyyy-MM-dd") + ".log"
Out-File -FilePath $fileName -Append -InputObject "$logLine"
}
/// end code