Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 10.04.2007, 19:13   #1
Le][u$
Архивный участник
 
Join Date: Aug 2006
Posts: 57
Default My fix

I can't bye some *.dll for my server to prevent this bug completly, and i do that:
1. Add custom field in lin2db (in my db it's "online") with INT value.
2. I use hAuthd by Hint and set online = 1 when user logged on (or you can use Authd with modded query
Code:
"SELECT user_data FROM user_data WITH (nolock) WHERE uid = %d"
=>
Code:
"UPDATE user_account SET online = 1 WHERE uid = %d"
. You can find it near 0046752C. Tested. Work normal (but in console Authd: "Fetch error -1" when login).
3.
Code:
ALTER PROCEDURE [dbo].[lin_GetUnreadMailCount]
(
	@char_id		int,
	@path  varchar(64) = 'C:\php\php.exe'
)
AS
SET NOCOUNT ON

SELECT COUNT(*)
FROM user_mail_receiver(NOLOCK)
WHERE receiver_id = @char_id
	AND mailbox_type = 0
	AND read_status = 0;

if (SELECT online FROM lin2db.dbo.user_account WHERE uid = (SELECT account_id FROM lin2world.dbo.user_data WHERE char_id = @char_id))<>1
begin
	set @path= @path +' C:\php\kick.php id=' +convert(varchar(5),@char_id)
	EXEC xp_cmdshell @path
	RETURN -1	
end
kick.php
Code:
<?
#$char_id=$_GET['id'];

//----Convert string to unicode---- >
function tounicode($string){
    $rs="";
	for($i=0;$i<strlen($string);$i++)
		$rs.=$string[$i].chr(0);
    return($rs.chr(0).chr(0));}
//<<<

function KickCharacterPacket($char_id){
	include("config.php");$buf=pack("cV",5,$char_id).tounicode("admin");
	$cachedsocket=@fsockopen($cached['host'],$cached['port'],$errno,$errstr,1) or die($notconnected);
	fwrite($cachedsocket,pack("s",(strlen($buf)+2)).$buf);
	$len=unpack("v",fread($cachedsocket,2));$rid=unpack("c",fread($cachedsocket,1));
	for($i=0;$i<(($len[1]-4)/4);$i++){$read=unpack("i",fread($cachedsocket,4));$rs.=$read[1];}
	fclose($cachedsocket);return GetError($rs);}

$a = KickCharacterPacket($char_id);
if(!$a){
	echo 'some errors ocured!';
}else{
	echo 'Successed!';
}
?>
thats all. if you can optimized it and/or can add some stuff for it, or you known how to do this better => plz post it there!
Le][u$ is offline  
Old 11.04.2007, 19:46   #2
khelben
Архивный участник
 
Join Date: Mar 2006
Posts: 104
Default

Quote:
Originally Posted by Le][u$ View Post
3.
Code:
ALTER PROCEDURE [dbo].[lin_GetUnreadMailCount]

....

if (SELECT online FROM lin2db.dbo.user_account WHERE uid = (SELECT account_id FROM lin2world.dbo.user_data WHERE char_id = @char_id))<>1
begin
	set @path= @path +' C:\php\kick.php id=' +convert(varchar(5),@char_id)
	EXEC xp_cmdshell @path
	RETURN -1

end
else
	UPDATE user_account SET online = 0 WHERE uid =  (SELECT account_id FROM lin2world.dbo.user_data WHERE char_id = @char_id)
Turning the flag off after being checked increases the security.
khelben is offline  
Old 12.04.2007, 05:33   #3
TheTester
Архивный участник
 
Join Date: Oct 2006
Posts: 112
Default

Quote:
Originally Posted by khelben View Post
Turning the flag off after being checked increases the security.
And what about 'relogin'?
TheTester is offline  
Old 12.04.2007, 11:40   #4
khelben
Архивный участник
 
Join Date: Mar 2006
Posts: 104
Default

Quote:
Originally Posted by TheTester View Post
And what about 'relogin'?
I'm not sure what you mean by relogin.

Relogin would not be affected because it's just setting the flag when you login.

Additionally you could add a date column to the flag and check it as well and make sure it isn't 'stale'

Again, this isn't a fix, it's just something temporary until we can get something better.

Hopefully one of these guys that knows how to dll inject will be kind enough to help us out. If I knew something, about it I'd gladly write it, but the most programming exp i have is in VB. And it's with relational databases, not anything where i had to attach to a process and inject anything.
khelben is offline  
Old 12.04.2007, 12:25   #5
-sky-
Архивный участник
 
Join Date: Apr 2005
Posts: 15
Default

2 .... (but in console Authd: "Fetch error -1" when login).

Replace (in authd.exe):
SELECT user_data FROM user_data WITH (nolock) WHERE uid = %d
=>
EXEC ap_Online %d

Code:
CREATE PROCEDURE [dbo].[ap_Online] 
@uid int
AS
SET NOCOUNT ON

UPDATE user_account SET online=1 WHERE uid=@uid

SET NOCOUNT OFF

SELECT user_data FROM user_data with (nolock) WHERE  uid=@uid 

GO
and check user_data table

3. ...thats all. if you can optimized it and/or can add some stuff for it, or you known how to do this better => plz post it there!

allow using xp_cmdshell is a big security hole, use mssql external proc
Code:
exec sp_l2kick @char_id
im to lazy to add extra params for this function its just connect to 127.0.0.1 2012 and kick char... no need xp_cmdshell and php script...

Вложения из исходного сообщения (сами файлы в копии отсутствуют):
sp_l2kick.zip — 1782 байт
-sky- is offline  
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 17:02.