Login
Username
Password

Register
Lost Password
Black Zero
Black Zero
Black Zero Black Zero
Black-Zero :: View topic - FindFirstFile, FindNextFile API function question
Black-Zero Forum Index » Coding » FindFirstFile, FindNextFile API function question

 
Post new topic   Reply to topic    Black-Zero Forum Index » Coding
Author Message
the_labrat
Newbie
Newbie


Joined: Nov 15, 2008
Posts: 8
Points: 365

Reply with quote
PostPosted: Mon Nov 17, 2008 3:39 am    Post subject: FindFirstFile, FindNextFile API function question

*I heard somewhere that each directory in windows contains two folders/files : "." and ".." Can anyone confirm and explain that for us .

*Also, i made some code in VB6 to add the file names in a directory to a combo box. I made it with reference to sample source codes, and to ensure that the "." and ".." file names are not added to the combo box, the code first removes any nulls in the file name, and then checks if its the "." or ".." -> the last part is a little trivial.
As you'll see in he code below (which works well the way it is), an if_statement checks if the filename is BOTH "." and ".." at the same time, and if so, then the file name is not added to the combobox.
>>so how is it that we need to check if a filename is not both "." and ".." at the same time; so that these file names are not added to the combo box???

the code: - you should declare the FindFirstFiles and FindNxtFile APi functions first......if you cant, PM me....
Code:

Private Sub FillCombo()
'On Error GoTo err
Dim path As String, fileName As String, hSearch As Long, _
wfd As WIN32_FIND_DATA, cont As Integer
    path = App.path & "\ccc\*.*"
    hSearch = FindFirstFile(path, wfd)
    cont = 1
    Do While cont <> 0
        fileName = StripNulls(wfd.cFileName)
        If fileName <> "." And fileName <> ".." Then cmb.AddItem Left(fileName, Len(fileName) - 4)
        cont = FindNextFile(hSearch, wfd)
    Loop
    lblCount.Caption = cmb.ListCount & " *.au3 files."
    FindClose hSearch
    Exit Sub
err:
    MsgBox "some error"
End Sub
Function StripNulls(OriginalStr As String) As String
    If (InStr(OriginalStr, Chr(0)) > 0) Then
        OriginalStr = Left(OriginalStr, InStr(OriginalStr, Chr(0)) - 1)
    End If
    StripNulls = OriginalStr
End Function

____________
whats worse than getting owned
-> not knowing it....
View user's profile Send private message
the_labrat
Newbie
Newbie


Joined: Nov 15, 2008
Posts: 8
Points: 365

Reply with quote
PostPosted: Mon Dec 08, 2008 12:30 am    Post subject:

oh, you'll need
1> a combo box named "cmb"
2> a label named> "lblCount"
3> a brain and some intellect
4> if u have no. 3, then u should have a comp with VS [am writing this just in case].

The directory your code is chacking is stored in the variable "path".
My code sets it to "app.path & "\ccc""
and that's coz i had that particular directory in my HDD
So u should set it to a directory u have> get nifty and use a few text boxes, file-list boxes....and such here and there.
It'll be fun, and u'll learn a lot. Make this code more useful
____________
whats worse than getting owned
-> not knowing it....
View user's profile Send private message
BinaryShinigami
Newbie
Newbie


Joined: Apr 21, 2009
Posts: 5
Points: 275

Reply with quote
PostPosted: Thu Jun 25, 2009 10:32 am    Post subject:

I don't play with VB so I can't comment on the code but I can tell you that windows does have 2 directories named . and .. in each folder. The "." directory is a reference to the current directory you are in and the ".." directory is a reference to the next highest folder in the hierarchy. So for example, if you were to have a folder setup like this:
C:\Users\Binary and you were in Binary then "." would point to C:\Users\Binary\ and ".." would point to C:\Users\

This is helpful for directory transversal if you are attacking a site vulnerable to LFI you and the files included were in C:\includes\ and you wanted to get a file from C:\passwordFiles\ then you could inject ..\passwordFiles\passwordFileYouWant.
____________
A.K.A DigitalOutcast
Rawr!
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Black-Zero Forum Index -> Coding All times are GMT - 6 Hours
Page 1 of 1

Jump to:  
Black Zero Black Zero
Black Zero
 
Users Online : 14   Guests Online : 22

DonPC  mhdm  sherlockH  TrueHacker  John_W  vbms  dr5w1  Cobruto  retfiremedic  
Pet  Cyber_Mafia  f1sH  MAW  fonzo234