My site was attacked by injection

Started on the old forum in February 2018 · view the original in the archive · old links redirect here

#something-else

2 replies · 144 views · started 8 years ago · 1 min read

3 participants
tupac Developer · 95 posts #1

Hello guys, my site was attacked and the hacker claims it was done by a simple injection in ip, we all know hackers don't reveal the true ways of executing their attacks, however, would just like to verify if my ip code seems vulnerable or not?

function getip()

{

if($_SERVER["REMOTE_ADDR"])

{ $ip=$_SERVER["REMOTE_ADDR"];

} else { $ip=$_SERVER["HTTP_X_FORWARDED_FOR"];}

if(strpos($ip,",")){

$exp_ip=explode(",",$ip);

$ip=$exp_ip[0];

}

return $ip;

}

something else Fellow · 2,296 posts #2

Yes its vulnerable. HTTP_X_FORWARDED_FOR can be easily spoofed use mysql_escape_string() to make it safe.

ACIDCORE Junior · 30 posts #3

I think you should try to use prepared statements. I know its a lot easier to code using procedural way but there are lots of glitches when scaping vars there. We shouldI think you should try to use prepared statements. I know its a lot easier to code using procedural way but there are lots of glitches when scaping vars there. We should move on now. There are lots of frameworks to use or you can make one. Just a friendly reminder.

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close