Testing the Network Alert System 2.0 [ Log In | Register ]       

r00tsecurity: [C - Win] File Lister - r00tsecurity

Jump to content

Carders Placecredit cards & transfers
carders-place.com
Ferbourtoi.orgWhere We Provide...
ferbourtoi.org
DirtymusicDirtymusic
dirtymusic.co.uk
StoleThe.NetFree Rapidshare Downloads
stolethe.net
ZaraByteHack like the PROS
ZaraByte.com
ADVERTISE HEREAdvertise here for cheap...
www.r00tsecurity.org
ADVERTISE HEREAdvertise here for cheap...
www.r00tsecurity.org
Ads by r00tsecurity.org

FORUM RULES

This is a discussion forum. Questions, Serious Articles/Guides & Discussion Based Topics Only

RELATED NETWORK CONTENT => Example/Source Code Database || Article/Tutorial Database ||Submit Source Code || Submit Article
Page 1 of 1

[C - Win] File Lister Recursive File lister for windows.

#1 User is offline   (elchupathingy) Icon

  • Website Dev / Forum Mod



  • Group: (r00t staff)
  • Posts: 574
  • Joined: 27-August 08
  • LocationnoitacoL

Posted 23 March 2010 - 07:38 PM

#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
0

#2 User is offline   (d4rK) Icon

  • God of Anonymity
  • Group: (VIP)
  • Posts: 102
  • Joined: 18-January 08

Posted 31 March 2010 - 08:07 AM

looks good and definately useful on so many levels, love your snippets chupa keep em comin
0

#3 User is offline   (elchupathingy) Icon

  • Website Dev / Forum Mod



  • Group: (r00t staff)
  • Posts: 574
  • Joined: 27-August 08
  • LocationnoitacoL

Posted 31 March 2010 - 02:01 PM

np its what I will be doing :D

~ELChupathingy
0

ADVERTISE HEREAdvertise here for cheap...
www.r00tsecurity.org
ADVERTISE HEREAdvertise here for cheap...
www.r00tsecurity.org
ADVERTISE HEREAdvertise here for cheap...
www.r00tsecurity.org
ADVERTISE HEREAdvertise here for cheap...
www.r00tsecurity.org
ADVERTISE HEREAdvertise here for cheap...
www.r00tsecurity.org
ADVERTISE HEREAdvertise here for cheap...
www.r00tsecurity.org
Ads by r00tsecurity.org

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


Similar Topics Collapse

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Image SpotImage Hosting
imgspot.org
XtremeLiDirect Downloads
xtremeli.com
CysForum.comPowered By Warez
CysForum.com
Warez LegendWarez Forum
warez-legend.com
Warez GalaxyWarez Site
warezgalaxy.org
Wrz-XWarez Forum
wrz-x.net
ADVERTISE HEREAdvertise here for cheap...
www.r00tsecurity.org
Ads by r00tsecurity.org