logo
logo
Sign in
avatar
Mark Waltberg
Directory traversal



What is directory traversal?

An index crossing assault expects to get to records and catalogues that are put away external to the planned organizer. By controlling documents with "dab speck slice (../)" arrangements and its varieties, or by utilizing outright record ways, it very well might be feasible to get too erratic documents and catalogues put away on the filesystem; including application source code, setup, and other basic framework documents.


About this example

In this example, you will figure out how catalogue crossing functions and how to moderate it in your application. You will initially utilize a catalogue crossing assault to hack a weak web server. We will then, at that point, make sense of index crossing by showing you the backend code of that weak server. At last, we will show you how to keep index crossing from influencing your code.


Prepared to learn? Clasp your safety belts, put on your programmer's cap, and we should begin!

Catalogue crossing in real life


Hacking a to-do application

To increment income and make due until the following subsidizing cycle, an organization called startup.io chose to make a side item. Since the market for picture facilitating stages has as of late turned into a piece immersed, the firm settled on a decision to construct an application for figuring out how to plan for the day all things considered.


Unfortunately, their to-do application is powerless against directory traversal attacks. We should utilize a terminal window and twist to take advantage of the weakness. We want to see the/and so on/passwd put away on the backend server.


The application is facilitated on https://todoapp.startup.io. To begin with, how about we attempt to twist a page we ought to approach?


Duplicate the accompanying into the terminal: twist https://todoapp.startup.io/public/about.html

Posting the public page

a

We see the about.html page returned, as most would consider normal. Notice that this HTML page is being served from the public catalogue.


We should eliminate the about.html filename from this solicitation and check whether we can get a catalogue posting back.


Duplicate the accompanying into the terminal: twist https://todoapp.startup.io/public/

Bingo! We've figured out how to list the records in the public catalogue. This is certainly not an extreme hack yet, since we're still in the public registry. In any case, showing a registry posting like this is a type of superfluous data exposure.


Show one page up

Since we can list records in the public registry, perhaps we could likewise cross to different catalogues and see their items. We should add a ../onto the URL to separate it from the parent catalogue. Run the accompanying order:


Duplicate the accompanying into the terminal: twist https://todoapp.startup.io/public/../

Oh goodness, we've lost our index posting and are once more into HTML! Our effort to perform index crossing has been gotten! Sterilization exists, and it got our noxious exertion. It seems as though we've been returned to the to-do application landing page.


Avoiding sterilization

Our expectation isn't lost at this point! There is an alternate method for addressing a . in the web world: URL encoding. How about we attempt to avoid the disinfection by URL encoding the .s. Supplant the .s with %2e as follows:


Duplicate the accompanying into the terminal: twist https://todoapp.startup.io/public/%2e%2e/

Well done! You've broken out of the public registry. We can now move forward with our game and access some touchy data.


Getting to delicate data

I have an undeniable inclination we're running as the root client, so we should point large and attempt to get to some delicate framework data. For instance, we should get to the/and so on/password record. To do this, run the accompanying order:


Duplicate the accompanying into the terminal: twist https://todoapp.startup.io/public/%2e%2e/%2e%2e/and so on/passwd

Blast! We've figured out how to see the/and so on/password record. Envision what else we could uncover on the off chance that we looked around just a tad longer. Perhaps SSL declarations? Or on the other hand information base passwords with read/compose admittance to create data sets?


We should find out what turned out badly on the startup.io backend server, which permitted us to play out a directory traversal assault.


Index crossing in the engine


How does index crossing work?

Basically, the assault is achieved by adding characters, for example, ../into a URL that serves content from an index structure. The substance is generally served from a base registry, for example,/public. An aggressor can supply filenames that contain ../or a URL encoded comparable %2e%2e%2f. These URLs permit the assailant to break out of the base catalogue and view records put away in different envelopes on the filesystem.


collect
0
avatar
Mark Waltberg
guide
Zupyak is the world’s largest content marketing community, with over 400 000 members and 3 million articles. Explore and get your content discovered.
Read more