[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r8708: (in torpedo/trunk: . src src/usbdrivedetect)



Author: sn275
Date: 2006-10-13 17:53:33 -0400 (Fri, 13 Oct 2006)
New Revision: 8708

Added:
   torpedo/trunk/src/
   torpedo/trunk/src/usbdrivedetect/
   torpedo/trunk/src/usbdrivedetect/ReadMe.txt
   torpedo/trunk/src/usbdrivedetect/drivedetect.cpp
   torpedo/trunk/src/usbdrivedetect/stdafx.cpp
   torpedo/trunk/src/usbdrivedetect/stdafx.h
   torpedo/trunk/src/usbdrivedetect/usbdrivedetect.ncb
   torpedo/trunk/src/usbdrivedetect/usbdrivedetect.sln
   torpedo/trunk/src/usbdrivedetect/usbdrivedetect.suo
   torpedo/trunk/src/usbdrivedetect/usbdrivedetect.vcproj
   torpedo/trunk/todo
Log:


Added: torpedo/trunk/src/usbdrivedetect/ReadMe.txt
===================================================================
--- torpedo/trunk/src/usbdrivedetect/ReadMe.txt	2006-10-13 20:43:02 UTC (rev 8707)
+++ torpedo/trunk/src/usbdrivedetect/ReadMe.txt	2006-10-13 21:53:33 UTC (rev 8708)
@@ -0,0 +1,32 @@
+========================================================================
+    CONSOLE APPLICATION : torpedo Project Overview
+========================================================================
+
+AppWizard has created this torpedo application for you.  
+This file contains a summary of what you will find in each of the files that
+make up your torpedo application.
+
+
+torpedo.vcproj
+    This is the main project file for VC++ projects generated using an Application Wizard. 
+    It contains information about the version of Visual C++ that generated the file, and 
+    information about the platforms, configurations, and project features selected with the
+    Application Wizard.
+
+torpedo.cpp
+    This is the main application source file.
+
+/////////////////////////////////////////////////////////////////////////////
+Other standard files:
+
+StdAfx.h, StdAfx.cpp
+    These files are used to build a precompiled header (PCH) file
+    named torpedo.pch and a precompiled types file named StdAfx.obj.
+
+/////////////////////////////////////////////////////////////////////////////
+Other notes:
+
+AppWizard uses "TODO:" comments to indicate parts of the source code you
+should add to or customize.
+
+/////////////////////////////////////////////////////////////////////////////


Property changes on: torpedo/trunk/src/usbdrivedetect/ReadMe.txt
___________________________________________________________________
Name: svn:executable
   + *

Added: torpedo/trunk/src/usbdrivedetect/drivedetect.cpp
===================================================================
--- torpedo/trunk/src/usbdrivedetect/drivedetect.cpp	2006-10-13 20:43:02 UTC (rev 8707)
+++ torpedo/trunk/src/usbdrivedetect/drivedetect.cpp	2006-10-13 21:53:33 UTC (rev 8708)
@@ -0,0 +1,220 @@
+/* Copyright S. Nagaraja */
+/* Licensed to Tor.eff.org */
+/* alright we'll get this crap right next time*/
+
+
+// torpedo.cpp : Defines the entry point for the console application.
+//
+
+#include "stdafx.h"
+
+
+#include <stdio.h>
+
+#include <windows.h>
+#include <dbt.h>						// For DeviceChange.
+#include <winioctl.h>					// For DeviceIOCtl.
+
+#define MAX_LOADSTRING 100
+
+// Add fro USB Task.
+
+// USB letters' container
+TCHAR   szMoveDiskName[33];
+TCHAR	szDrvName[33];
+BOOL	bInitUSBs;
+// Drive type names
+#define DRVUNKNOWN		0
+#define DRVFIXED		1
+#define DRVREMOTE		2
+#define DRVRAM			3
+#define DRVCD			4
+#define DRVREMOVE		5
+
+// IOCTL control code
+#define IOCTL_STORAGE_QUERY_PROPERTY   CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS)
+
+
+// retrieve the storage device descriptor data for a device. 
+typedef struct _STORAGE_DEVICE_DESCRIPTOR {
+  ULONG  Version;
+  ULONG  Size;
+  UCHAR  DeviceType;
+  UCHAR  DeviceTypeModifier;
+  BOOLEAN  RemovableMedia;
+  BOOLEAN  CommandQueueing;
+  ULONG  VendorIdOffset;
+  ULONG  ProductIdOffset;
+  ULONG  ProductRevisionOffset;
+  ULONG  SerialNumberOffset;
+  STORAGE_BUS_TYPE  BusType;
+  ULONG  RawPropertiesLength;
+  UCHAR  RawDeviceProperties[1];
+
+} STORAGE_DEVICE_DESCRIPTOR, *PSTORAGE_DEVICE_DESCRIPTOR;
+
+// retrieve the properties of a storage device or adapter. 
+typedef enum _STORAGE_QUERY_TYPE {
+  PropertyStandardQuery = 0,
+  PropertyExistsQuery,
+  PropertyMaskQuery,
+  PropertyQueryMaxDefined
+
+} STORAGE_QUERY_TYPE, *PSTORAGE_QUERY_TYPE;
+
+// retrieve the properties of a storage device or adapter. 
+typedef enum _STORAGE_PROPERTY_ID {
+  StorageDeviceProperty = 0,
+  StorageAdapterProperty,
+  StorageDeviceIdProperty
+
+} STORAGE_PROPERTY_ID, *PSTORAGE_PROPERTY_ID;
+
+// retrieve the properties of a storage device or adapter. 
+typedef struct _STORAGE_PROPERTY_QUERY {
+  STORAGE_PROPERTY_ID  PropertyId;
+  STORAGE_QUERY_TYPE  QueryType;
+  UCHAR  AdditionalParameters[1];
+
+} STORAGE_PROPERTY_QUERY, *PSTORAGE_PROPERTY_QUERY;
+
+
+
+/****************************************************************************
+*
+*    FUNCTION: GetDisksProperty(HANDLE hDevice, PSTORAGE_DEVICE_DESCRIPTOR pDevDesc)
+*
+*    PURPOSE:  get the info of specified device
+*
+****************************************************************************/
+BOOL GetDisksProperty(HANDLE hDevice, PSTORAGE_DEVICE_DESCRIPTOR pDevDesc)
+{
+	STORAGE_PROPERTY_QUERY	Query;	// input param for query
+	DWORD dwOutBytes;				// IOCTL output length
+	BOOL bResult;					// IOCTL return val
+
+	// specify the query type
+	Query.PropertyId = StorageDeviceProperty;
+	Query.QueryType = PropertyStandardQuery;
+
+	// Query using IOCTL_STORAGE_QUERY_PROPERTY 
+	bResult = ::DeviceIoControl(hDevice,			// device handle
+			IOCTL_STORAGE_QUERY_PROPERTY,			// info of device property
+			&Query, sizeof(STORAGE_PROPERTY_QUERY),	// input data buffer
+			pDevDesc, pDevDesc->Size,				// output data buffer
+			&dwOutBytes,							// out's length
+			(LPOVERLAPPED)NULL);					
+
+	return bResult;
+}
+
+/****************************************************************************
+*
+*    FUNCTION: chFirstDriverFrameMask(ULONG unitmask)
+*
+*    PURPOSE:  get the logic name of driver
+*
+****************************************************************************/
+char chFirstDriveFromMask (ULONG unitmask)
+{
+
+      char i;
+      for (i = 0; i < 26; ++i)  
+      {
+           if (unitmask & 0x1) 
+				break;
+            unitmask = unitmask >> 1;
+      }
+    return (i + 'A');
+}
+
+/****************************************************************************
+*
+*    FUNCTION: ReInitUSB_Disk_Letter()
+*
+*    PURPOSE:  get the usb disks, and filling the 'szMoveDiskName' with them
+*
+****************************************************************************/
+void ReInitUSB_Disk_Letter()
+{
+	int k = 0;
+	DWORD			MaxDriveSet, CurDriveSet;
+	DWORD			drive, drivetype;
+	TCHAR			szBuf[300];
+	HANDLE			hDevice;
+	PSTORAGE_DEVICE_DESCRIPTOR pDevDesc;
+
+	for(k=0; k<26; k++)
+		szMoveDiskName[k] = '\0';	
+	k = 1;		
+	// Get available drives we can monitor
+	MaxDriveSet = CurDriveSet = 0;
+
+	MaxDriveSet = GetLogicalDrives();
+	CurDriveSet = MaxDriveSet;
+	for ( drive = 0; drive < 32; ++drive )  
+	{
+		if ( MaxDriveSet & (1 << drive) )  
+		{
+			DWORD temp = 1<<drive;
+			_stprintf( szDrvName, _T("%c:\\"), 'A'+drive );
+			switch ( GetDriveType( szDrvName ) )  
+			{
+				case 0:					// The drive type cannot be determined.
+				case 1:					// The root directory does not exist.
+					drivetype = DRVUNKNOWN;
+					break;
+				case DRIVE_REMOVABLE:	// The drive can be removed from the drive.
+					drivetype = DRVREMOVE;
+
+					sprintf(szBuf, "\\\\?\\%c:", 'A'+drive);
+					hDevice = CreateFile(szBuf, GENERIC_READ,
+								FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, NULL);
+
+					if (hDevice != INVALID_HANDLE_VALUE)
+					{
+
+						pDevDesc = (PSTORAGE_DEVICE_DESCRIPTOR)new BYTE[sizeof(STORAGE_DEVICE_DESCRIPTOR) + 512 - 1];
+
+						pDevDesc->Size = sizeof(STORAGE_DEVICE_DESCRIPTOR) + 512 - 1;
+
+						if(GetDisksProperty(hDevice, pDevDesc))
+						{
+							fprintf(stdout, "Bustype %d\n", pDevDesc->BusType);
+							if(pDevDesc->BusType == BusTypeUsb)
+							{
+								szMoveDiskName[k] = chFirstDriveFromMask(temp);
+								szMoveDiskName[0]=k;
+								k++;
+							}
+						}
+
+						delete pDevDesc;
+						CloseHandle(hDevice);
+					}
+			
+					break;
+
+				case DRIVE_CDROM:		// The drive is a CD-ROM drive.
+					break;
+				
+			}
+		}
+	}
+
+}
+
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+
+	fprintf(stdout, "Hello World\n");
+	ReInitUSB_Disk_Letter();
+	
+	fprintf(stdout, "Removable disk %s\n", &szMoveDiskName[1]);	
+
+	
+
+	return 0;
+}
+


Property changes on: torpedo/trunk/src/usbdrivedetect/drivedetect.cpp
___________________________________________________________________
Name: svn:executable
   + *

Added: torpedo/trunk/src/usbdrivedetect/stdafx.cpp
===================================================================
--- torpedo/trunk/src/usbdrivedetect/stdafx.cpp	2006-10-13 20:43:02 UTC (rev 8707)
+++ torpedo/trunk/src/usbdrivedetect/stdafx.cpp	2006-10-13 21:53:33 UTC (rev 8708)
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// torpedo.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file


Property changes on: torpedo/trunk/src/usbdrivedetect/stdafx.cpp
___________________________________________________________________
Name: svn:executable
   + *

Added: torpedo/trunk/src/usbdrivedetect/stdafx.h
===================================================================
--- torpedo/trunk/src/usbdrivedetect/stdafx.h	2006-10-13 20:43:02 UTC (rev 8707)
+++ torpedo/trunk/src/usbdrivedetect/stdafx.h	2006-10-13 21:53:33 UTC (rev 8708)
@@ -0,0 +1,12 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+
+#include <iostream>
+#include <tchar.h>
+
+// TODO: reference additional headers your program requires here


Property changes on: torpedo/trunk/src/usbdrivedetect/stdafx.h
___________________________________________________________________
Name: svn:executable
   + *

Added: torpedo/trunk/src/usbdrivedetect/usbdrivedetect.ncb
===================================================================
(Binary files differ)


Property changes on: torpedo/trunk/src/usbdrivedetect/usbdrivedetect.ncb
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: torpedo/trunk/src/usbdrivedetect/usbdrivedetect.sln
===================================================================
--- torpedo/trunk/src/usbdrivedetect/usbdrivedetect.sln	2006-10-13 20:43:02 UTC (rev 8707)
+++ torpedo/trunk/src/usbdrivedetect/usbdrivedetect.sln	2006-10-13 21:53:33 UTC (rev 8708)
@@ -0,0 +1,21 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "usbdrivedetect", "usbdrivedetect.vcproj", "{95A64579-5208-4B6A-9F45-63D3647FC95B}"
+	ProjectSection(ProjectDependencies) = postProject
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfiguration) = preSolution
+		Debug = Debug
+		Release = Release
+	EndGlobalSection
+	GlobalSection(ProjectConfiguration) = postSolution
+		{95A64579-5208-4B6A-9F45-63D3647FC95B}.Debug.ActiveCfg = Debug|Win32
+		{95A64579-5208-4B6A-9F45-63D3647FC95B}.Debug.Build.0 = Debug|Win32
+		{95A64579-5208-4B6A-9F45-63D3647FC95B}.Release.ActiveCfg = Release|Win32
+		{95A64579-5208-4B6A-9F45-63D3647FC95B}.Release.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+	EndGlobalSection
+	GlobalSection(ExtensibilityAddIns) = postSolution
+	EndGlobalSection
+EndGlobal


Property changes on: torpedo/trunk/src/usbdrivedetect/usbdrivedetect.sln
___________________________________________________________________
Name: svn:executable
   + *

Added: torpedo/trunk/src/usbdrivedetect/usbdrivedetect.suo
===================================================================
(Binary files differ)


Property changes on: torpedo/trunk/src/usbdrivedetect/usbdrivedetect.suo
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: torpedo/trunk/src/usbdrivedetect/usbdrivedetect.vcproj
===================================================================
--- torpedo/trunk/src/usbdrivedetect/usbdrivedetect.vcproj	2006-10-13 20:43:02 UTC (rev 8707)
+++ torpedo/trunk/src/usbdrivedetect/usbdrivedetect.vcproj	2006-10-13 21:53:33 UTC (rev 8708)
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="usbdrivedetect"
+	ProjectGUID="{95A64579-5208-4B6A-9F45-63D3647FC95B}"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="Debug"
+			IntermediateDirectory="Debug"
+			ConfigurationType="1"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="5"
+				UsePrecompiledHeader="3"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(OutDir)/torpedo.exe"
+				LinkIncremental="2"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile="$(OutDir)/torpedo.pdb"
+				SubSystem="1"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="Release"
+			IntermediateDirectory="Release"
+			ConfigurationType="1"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				RuntimeLibrary="4"
+				UsePrecompiledHeader="3"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(OutDir)/torpedo.exe"
+				LinkIncremental="1"
+				GenerateDebugInformation="TRUE"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+			<File
+				RelativePath=".\drivedetect.cpp">
+			</File>
+			<File
+				RelativePath=".\stdafx.cpp">
+				<FileConfiguration
+					Name="Debug|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"/>
+				</FileConfiguration>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+			<File
+				RelativePath=".\stdafx.h">
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+		</Filter>
+		<File
+			RelativePath=".\ReadMe.txt">
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>


Property changes on: torpedo/trunk/src/usbdrivedetect/usbdrivedetect.vcproj
___________________________________________________________________
Name: svn:executable
   + *

Added: torpedo/trunk/todo
===================================================================
--- torpedo/trunk/todo	2006-10-13 20:43:02 UTC (rev 8707)
+++ torpedo/trunk/todo	2006-10-13 21:53:33 UTC (rev 8708)
@@ -0,0 +1,74 @@
+############# TOR on a stick ##############
+
+Requirements for the first version:
+- Non-dataleaking browser with SOCKS_V5
+- thin web proxy
+- Chat client.
+- software installation.
+- not expecting any USB dumping software on the host, nor expecting
+any sort of surveillance programs to be sitting there.
+- User attitude towards TOR: I don't need to know I am actually using TOR.
+on a url should open the page in the correct browser.
+
+Requirements in the longer run: 
+- Directory caching.  
+- move away from SOCKS5 assumption, consider capturing winsock
+requests throught sockscap or winpcap and pointing them all to TOR.
+
+
+
+
+
+Documentation
+
+Build Process
+
+Project tracking
+
+
+
+
+---------------------------------------------
+To do list ( in decreasing order of priority )
+
+1) Firefox changes:
+   - source baseline portable firefox.
+   - list1: appropriate features
+   - list2: inappropriate features and call trace examination.
+   - disable list2 and iterate.
+
+2) Installation: How do we get the firefox on USB to be the one that
+is used. possible approaches:   
+   - study DMA access methods, look at Maximillian's DMA ipod attack code.
+   - nsi
+
+3) Usability features
+- Making the browser look different from standard firefox. Torpark
+does a decent job at this, it might be an idea to borrow UI features
+from there.
+- TOR button.
+- Inputs from Peter Gutmann's defcon talk.
+- Inputs from Roger and others.
+   
+4) Thin proxy:
+   evaluate polipo. 
+   
+5) Chat client
+   Google talk? It seems to have proxy support.
+   Scatterchat/Gaim is another alternative (probably better).
+
+------------------------------------------------------
+Delivery 1:
+
+What we have: A utility that detects the drive letter of the usb disk
+
+what we need: 
+
+1) A config utility that is automatically started, when the usb disk
+is mounted written using shell scripts or in C.  The job of this is to
+make firefox, vidalia, polipo/privoxy and Tor happy to start.
+
+2) An install program that installs Tor, firefox, vidalia,
+polipo/privoxy, and gaim on the usb disk.
+
+Completion date: Next weekend, 22 October 2006


Property changes on: torpedo/trunk/todo
___________________________________________________________________
Name: svn:executable
   + *