#include <stdio.h>
#include <tchar.h>
#include <stdlib.h>
#include <windows.h>
int DisplayDir( char *path )
{
WIN32_FIND_DATA data;
HANDLE f = FindFirstFile( path, &data );
if( f == INVALID_HANDLE_VALUE )
{
printf( "[*] Could not open or the argument was not a valid file\nExiting..." );
return 0;
}
do
{
if( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
char tmp2[MAX_PATH] = "";
strcpy( tmp2, path );
tmp2[strlen( tmp2 ) - 2] = '\0';
sprintf( tmp2, "%s\\%s\\*", tmp2, data.cFileName );
if( ( strstr( data.cFileName, "." ) != 0 || strstr( data.cFileName, ".." ) != 0 ) )
continue;
DisplayDir( tmp2 );
}
else
{
printf( "%s\n", data.cFileName );
}
}
while( FindNextFile( f, &data ) != 0 );
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
if( argc != 2 )
{
printf( "Useage: outfile.exe <directory>\n~ELChupathingy" );
return 0;
}
char final_path[MAX_PATH] = {};
strcpy( final_path, argv[1] );
final_path[strlen( final_path ) - 3] = '\0';
sprintf( final_path, "%s\\*", final_path );
sprintf( final_path, "%s\\*\0", argv[1] );
printf( "[*] Searching through %s\n", final_path );
printf( "[*] Recursivly looking through folders and printing to console\n" );
DisplayDir( final_path );
printf( "[*] Listing Finished\n" );
return 0;
}
Example dump:
[*] Searching through C:\Project\outfiles\* [*] Recursivly looking through folders and printing to console outfiles.exe outfiles.ilk outfiles.pdb test.bat BuildLog.htm mt.dep outfiles.exe.embed.manifest outfiles.exe.embed.manifest.res outfiles.exe.intermediate.manifest outfiles.obj outfiles.pch stdafx.obj vc90.idb vc90.pdb outfiles.cpp outfiles.vcproj outfiles.vcproj.TRAFFICLAND.sreed.user ReadMe.txt BuildLog.htm mt.dep outfiles.exe.intermediate.manifest outfiles.obj outfiles.pch stdafx.obj vc90.idb vc90.pdb stdafx.cpp stdafx.h targetver.h outfiles.ncb outfiles.sln outfiles.suo outfiles.exe output.txt out_files.zip test.bat [*] Listing Finished
Does not list directory's but that is pretty much just a single line change.
~ELChupathingy
// outfiles.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int DisplayDir( char *path, int d )
{
WIN32_FIND_DATA data;
HANDLE f = FindFirstFile( path, &data );
if( f == INVALID_HANDLE_VALUE )
{
printf( "[*] Could not open or the argument was not a valid file\nExiting..." );
return 0;
}
do
{
if( d > 0 )
{
for( int i = 0; i < d; i++ )
{
putchar( ' ' );
}
}
if( !( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
putchar( '+' );
if( data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
char tmp2[MAX_PATH] = "";
strcpy( tmp2, path );
tmp2[strlen( tmp2 ) - 2] = '\0';
sprintf( tmp2, "%s\\%s\\*", tmp2, data.cFileName );
if( ( strstr( data.cFileName, "." ) != 0 || strstr( data.cFileName, ".." ) != 0 ) )
continue;
printf( "%s\t<DIR>\n", data.cFileName );
DisplayDir( tmp2, d + 1 );
}
else
{
printf( "%s\t%db\n", data.cFileName, data.nFileSizeLow );
}
}
while( FindNextFile( f, &data ) != 0 );
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
if( argc != 2 )
{
printf( "Useage: outfile.exe <directory>\n~ELChupathingy" );
return 0;
}
char final_path[MAX_PATH] = {};
strcpy( final_path, argv[1] );
final_path[strlen( final_path ) - 3] = '\0';
sprintf( final_path, "%s\\*", final_path );
sprintf( final_path, "%s\\*\0", argv[1] );
printf( "[*] Searching through %s\n", final_path );
printf( "[*] Recursivly looking through folders and printing to console\n" );
DisplayDir( final_path, 0 );
printf( "[*] Listing Finished\n" );
return 0;
}
Prints out nicer :D but other version is more useful imo
~ELChupathingy








MultiQuote

