help on htaccess

Started on the old forum in January 2012 · view the original in the archive · old links redirect here

3 replies · 484 views · started 14 years ago · 1 min read

2 participants
ozziemale31 Lead · 861 posts #1

im not a newby in coding but am stuck i have made a htaccess script that will log an attempted sqli attack email it to u and log it in a .txt page.

now what i need help in is some sort of htaccess code that will just select the ips from that .txt page

if anyone has an idea on howto do this any input will be highly regarded tried searching google for examples but no luck just how to ban an ip in the actual htaccess not from a external page

External image (may be gone) External image (may be gone)

External image (may be gone)

*****

**Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer.. Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free ***

arnage Lead · 811 posts #2

Im not sure that htaccess can read from file bro. Whats the idea with it? Maybe php to read from that txt and write it to htaccess?

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
ozziemale31 Lead · 861 posts #3

well ive made it so any sqli attempt is logged to a text file with browser ip and command they used it then emails u a copy of the log it would be kool if htaccess could be used to list those logged ips as an auto ip bann to the server automatically im sure theres a way to do it

External image (may be gone) External image (may be gone)

External image (may be gone)

*****

**Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer.. Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free ***

ozziemale31 Lead · 861 posts #4

think i may have found my solution

<?php

$ip = "deny from $REMOTE_ADDR\n" ;
$banip = '.htaccess';
$fp = fopen($banip, "a");
$write = fputs($fp, $ip);
fclose($fp);

//@ symbol hides errors from visitors
@mail('you@yourdmain.whatever',
'Banned IP '.$_SERVER['REMOTE_ADDR'].
' at '.$_SERVER['HTTP_REFERER'],
' IP '.$_SERVER['REMOTE_ADDR'].' banned'.
' request URI '.$_SERVER['REQUEST_URI'].
' referrer '.$_SERVER['HTTP_REFERER'].
' agent '.$_SERVER['HTTP_USER_AGENT'].
?>

this will write the ip to ban onto the htaccess file if it chmodded to 666 🙂 oh and email u the ban log

External image (may be gone) External image (may be gone)

External image (may be gone)

*****

**Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer.. Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free ***

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