v010dya
v010dya

Reputation: 5848

How to find what Javascript function redirects to a different URL

A website has had some sort of injection of Javascript code. It redirects via a chain of websites to some random location.

I have managed to find the exact URL that is being redirected to first, but cannot figure out how to attempt to find it in the code, to then be able to remove the problem (and then patch whatever hole there was on the site).

The only thing that i see on the Network tab of console is that the initiator of the request was an anonymous jQuery function, which doesn't help all that much. Is there a way to get this information?

P.S. It is possible i'm asking on the wrong project, in that case please point me in the right direction.

Upvotes: 0

Views: 146

Answers (1)

Seano666
Seano666

Reputation: 2238

This should allow you to debug/inspect the page before it redirects.

<script type="text/javascript">
        window.onbeforeunload = function(){
            debugger;
        };
</script>

Upvotes: 1

Related Questions