Størrelsen på en div i javascript [IE Only]

<div id='mydiv'>
Hvor hoej er den her crap div??<br><br><br>Saa hoej?
</div>
<script>
height=document.all["mydiv"].clientHeight || document.getElementById("mydiv").offsetHeight
width=document.all["mydiv"].clientWidth || document.getElementById("mydiv").offsetWidth
alert(height+' '+width)
document.write(document.mytab.style.offsetHeight);
</script>
Udgivet i Old Base, Programmering, Windows | Skriv en kommentar

Tailing dmesg [mike style]

while true; do clear; dmesg | tail; sleep 2; done;
Udgivet i Knowledge Base, Shellscript | Skriv en kommentar

Blaster removal

http://securityresponse.symantec.com/avcenter/venc/data/w32.blaster.worm.html

Udgivet i Old Base, Security | Skriv en kommentar

Blaster removal

http://securityresponse.symantec.com/avcenter/venc/data/w32.blaster.worm.html

Udgivet i Knowledge Base, Security | Skriv en kommentar

Easy way to make new passwords

On FreeBSD:
jot -r -c 160 a { | rs -g 0 8

It will output something like this:
whhmuqxn
amajtohu
ydtetwjw
ysnctfcl
svsiypsf
cvalnoex
dvoburbw
fedkcmfx
pikwqwiv
umaxmqcq
iqmtcnny
vsunccxj
owghvpgo
lndrpswr
flgtvyjz
vphojoqc
zofbcxto
reaixjhj
hmoeabtg
fukuimvk
//Vladimirr.dk
Udgivet i FreeBSD, Knowledge Base, Old Base | Skriv en kommentar

Register globals workaround

Be sure to think of the consequenses

<?
        if (!empty($_REQUEST)) { extract($_REQUEST); }
        print $fisk;
?>
Udgivet i Knowledge Base, Old Base | Skriv en kommentar

ProFTPD via MySQL

ProFTPD via MySQL
With mod_sql you can handle your user authentication in ProFTPD via an MySQL table.
Required is a fresh compiled actual ProFTPD with mod_sql enabled.

Enable mod_sql

./configure --with-modules=mod_sql:mod_sql_mysql


First you should create an new datebase named "proftpd" with a table named "users" in it.

Create the database and table

CREATE DATABASE proftpd;
CREATE TABLE `users` (
  `username` varchar(128) NOT NULL default '',
  `password` varchar(128) NOT NULL default '',
  `homedir` varchar(128) NOT NULL default '',
  `shell` varchar(128) NOT NULL default '',
  `uid` smallint(5) NOT NULL default '0',
  `gid` smallint(5) NOT NULL default '0',
  `last_login` datetime NOT NULL default '0000-00-00 00:00:00',
  `active` enum('0','1') NOT NULL default '1'
) TYPE=MyISAM;


Now add the following lines to your /etc/proftpd/proftpd.conf and restart the ProFTPD daemon.

/etc/proftpd/proftpd.conf

# MySQL
SQLAuthTypes         Plaintext
SQLAuthenticate      users*
SQLConnectInfo       <user>@<host> <database> <password>
SQLDefaultUID        65534
SQLDefaultGID        21
SQLMinUserUID        3000
SQLMinUserGID        21
SQLUserInfo          users username password uid gid homedir shell
SQLLog PASS login
SQLNamedQuery login UPDATE "last_login = NOW() WHERE username = '%u'" users
Udgivet i Knowledge Base, Old Base, SQL | Skriv en kommentar

sql til mod_sql_log

smid mod_sql_log ind:
http://www.outoforder.cc/projects/apache/mod_log_sql/'

guide:
http://www.linux-mag.com/2002-10/lamp_01.html

sæt flg i mod_sql_log.conf:

LogSQLLoginInfo             localhost apache KoDe
LogSQLSocketFile            /var/run/mysql/mysql.sock
LogSQLDatabase              apache
LogSQLCreateTables          On
LogSQLMassVirtualHosting    On
LogSQLPreserveFile          apache_queries.sql

nice queries:

# sidste 30 besøg med lidt relevant data
SELECT remote_host, request_uri, bytes_sent, status, FROM_UNIXTIME(time_stamp) AS dato from access_blackthorne_dk ORDER BY dato DESC LIMIT 30;

# besøg fra forskellige IP adresser
SELECT COUNT(*) AS visits, SUM(bytes_sent) AS bytes, remote_host FROM access_blackthorne_dk GROUP BY remote_host;

# besøg i alt og bytes i alt
SELECT COUNT(*) AS visits, SUM(bytes_sent) AS bytes FROM access_blackthorne_dk;

# besøg den sidste time
SELECT COUNT(*) FROM access_blackthorne_dk WHERE time_stamp BETWEEN UNIX_TIMESTAMP(NOW()) - 86400 AND UNIX_TIMESTAMP(NOW());

# besøg denne måned
SELECT COUNT(*) FROM access_blackthorne_dk WHERE MONTH(FROM_UNIXTIME(time_stamp)) = MONTH(NOW());
Udgivet i Apache, Knowledge Base, Old Base, SQL | Skriv en kommentar

Apache (2.x) logfiler i MySQL

Flg, får apache til at formattere logen og parse den til stdin på mysqllog.pl

CustomLog "| /usr/bin/mysqllog.pl" mysql
LogFormat "%h#%v#%U#%{User-agent}i#%{Referer}i#%s#%b#%r" mysql


Mysqllog parser så input til mysql:
#!/usr/bin/perl
# script: mysqllog
use DBI;
use constant DSN => 'dbi:mysql:system';
use constant DB_TABLE => 'access_log';
use constant DB_USER => 'root';
use constant DB_PASSWD => '--';

$db = DBI->connect(DSN,DB_USER,DB_PASSWD) || die DBI->errstr;
$sth = $db->prepare("INSERT INTO weblog (`remotehost`,`virtualhost`,`path`,`agent`,`referer`,`status`,`size`,`request`,`time`)
 VALUES(?,?,?,?,?,?,?,?,?)")
|| die $db->errstr;

while (<>) {
chomp;
@dat=split("#");
$sth->execute(@dat[0],@dat[1],@dat[2],@dat[3],@dat[4],@dat[5],@dat[6],@dat[7],time());
}
$sth->finish;
$db->disconnect;
Udgivet i Apache, Knowledge Base, Old Base | Skriv en kommentar

tunnel specifik protocol out from NAT’ed hosts

root@chilibeans ~/dksback# ssh -l mike unifix.org -R 13306:127.0.0.1:3306
mike@unifix.org's password:

here chilibeans are behind a nat firewall and does not have a public ip, this make me able to contact chilibeans's mysql server from unifix.org by connecting to 127.0.0.1:13306

unifix# mysql -h 127.0.0.1 --port=13306 -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 73 to server version: 4.0.18

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
Udgivet i Knowledge Base, Linux, Old Base | Skriv en kommentar