Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Execute a Command Line App from Stored Procedure

Execute a Command Line App from Stored Procedure

Scheduled Pinned Locked Moved Database
databasequestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kevin Nicol
    wrote on last edited by
    #1

    Hi All, I need to execute a command line executable from a stored procedure, any ideas on how I would do this? Thanks Kevin

    C 1 Reply Last reply
    0
    • K Kevin Nicol

      Hi All, I need to execute a command line executable from a stored procedure, any ideas on how I would do this? Thanks Kevin

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      It is an unwise thing to do because it is a security risk but you can use: xp_cmdshell[^]


      Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

      K 1 Reply Last reply
      0
      • C Colin Angus Mackay

        It is an unwise thing to do because it is a security risk but you can use: xp_cmdshell[^]


        Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

        K Offline
        K Offline
        Kevin Nicol
        wrote on last edited by
        #3

        Thanks, works great. Whats the security risk?

        F C 2 Replies Last reply
        0
        • K Kevin Nicol

          Thanks, works great. Whats the security risk?

          F Offline
          F Offline
          Frank Kerrigan
          wrote on last edited by
          #4

          A sql injection attack may use that to run any code on your server. Read Colin's article on SQL Injection attacks.


          Blog Have I http:\\www.frankkerrigan.com

          1 Reply Last reply
          0
          • K Kevin Nicol

            Thanks, works great. Whats the security risk?

            C Offline
            C Offline
            Colin Angus Mackay
            wrote on last edited by
            #5

            Kevin Nicol wrote:

            Whats the security risk?

            Allowing external commands to function outside of SQL Server opens some holes in a data based application. If a poorly written front appliction is attacked, or a firewall misconfigured, it is possible for an attacker to gain access to the SQL server and then from there launch commands on the server. The problem is exacerbated by the fact that many SQL Server installations are runing in the System Account. (If I remember correctly, this was the default before Service Pack 3. After that Full SQL Server installations suggested you create a specific account for SQL Server process to run in, however they still kept a nice handy radio button to swap it back to the system account - many lazy DBAs install SQL Server to use the system account). The system account has greater authority than the Admin account on the box. For example, did you ever notice in RegEdit that there are apparently empty folders called SECURITY in various locations? If you launch RegEdit in the system account you can see what's in there. But try it with an admin account and they look empty again. In my SQL Injection Attack presentations I use xp_cmdshell to show how an attacker can go in through a web application and rip a full directory listing off the hard disk. I could continue the presentation and actually have it stream a file that has been routed through SQL Server into the web application then over HTTP. I don't go that far because the directory listing trick is enough to get people to sit up and consider security more seriously.


            Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups