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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. The Lounge
  3. What could be the input?

What could be the input?

Scheduled Pinned Locked Moved The Lounge
databasecomhelptutorial
33 Posts 16 Posters 5 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.
  • E Espen Harlinn

    SELECT * FROM test WHERE id= /*/*/ 100

    No star needed, just /

    Espen Harlinn Senior Architect - Ulriken Consulting AS The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague.Edsger W.Dijkstra

    S Offline
    S Offline
    Sandeep Mewara
    wrote on last edited by
    #23

    Even if this works, INPUT cannot have * in it. :)

    Latest CodeProject post: Quick look into Machine Learning workflow How to solve Word Ladder Problem? To read all my blog posts, visit: Learn by Insight...

    E N 2 Replies Last reply
    0
    • S Sandeep Mewara

      What could be the value of input such that below query fails?

      SELECT * FROM test WHERE id= /* + INPUT + */ 100

      PS: You cannot put * in the value anywhere.

      Latest CodeProject post: Quick look into Machine Learning workflow How to solve Word Ladder Problem? To read all my blog posts, visit: Learn by Insight...

      P Offline
      P Offline
      Peter_in_2780
      wrote on last edited by
      #24

      Did you try: 1. HTML entities, like &#42 2. ASCII/Unicode in hex/octal \x2a \u002a \052 Some of those might sneak through. Just a thought from someone who knows nothing of your environment.

      Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

      1 Reply Last reply
      0
      • J Jon McKee

        Just tested this with MySQL and it works fine. What db does this fail with for you?

        E Offline
        E Offline
        Espen Harlinn
        wrote on last edited by
        #25

        SQL Server: Msg 113, Level 15, State 1, Line 1 Missing end comment mark '*/'. Msg 113, Level 15, State 1, Line 1 Missing end comment mark '*/'. Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '='.

        Espen Harlinn Senior Architect - Ulriken Consulting AS The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague.Edsger W.Dijkstra

        J 1 Reply Last reply
        0
        • S Sandeep Mewara

          Even if this works, INPUT cannot have * in it. :)

          Latest CodeProject post: Quick look into Machine Learning workflow How to solve Word Ladder Problem? To read all my blog posts, visit: Learn by Insight...

          E Offline
          E Offline
          Espen Harlinn
          wrote on last edited by
          #26

          Quote:

          Even if this works, INPUT cannot have * in it.

          It doesn't - I just replaced " INPUT " with "/"

          Espen Harlinn Senior Architect - Ulriken Consulting AS The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague.Edsger W.Dijkstra

          1 Reply Last reply
          0
          • S Sandeep Mewara

            Even if this works, INPUT cannot have * in it. :)

            Latest CodeProject post: Quick look into Machine Learning workflow How to solve Word Ladder Problem? To read all my blog posts, visit: Learn by Insight...

            N Offline
            N Offline
            Nelek
            wrote on last edited by
            #27

            The used * are yours, not his

            M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

            1 Reply Last reply
            0
            • E Espen Harlinn

              SQL Server: Msg 113, Level 15, State 1, Line 1 Missing end comment mark '*/'. Msg 113, Level 15, State 1, Line 1 Missing end comment mark '*/'. Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '='.

              Espen Harlinn Senior Architect - Ulriken Consulting AS The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague.Edsger W.Dijkstra

              J Offline
              J Offline
              Jorgen Andersson
              wrote on last edited by
              #28

              Because SQL Server allows nested comment blocks. "Nested comments are supported. If the /* character pattern occurs anywhere within an existing comment, it is treated as the start of a nested comment and, therefore, requires a closing */ comment mark. If the closing comment mark does not exist, an error is generated." - SQL Server | Microsoft Docs[^]

              Wrong is evil and must be defeated. - Jeff Ello

              1 Reply Last reply
              0
              • S Sandeep Mewara

                What could be the value of input such that below query fails?

                SELECT * FROM test WHERE id= /* + INPUT + */ 100

                PS: You cannot put * in the value anywhere.

                Latest CodeProject post: Quick look into Machine Learning workflow How to solve Word Ladder Problem? To read all my blog posts, visit: Learn by Insight...

                D Offline
                D Offline
                DerekT P
                wrote on last edited by
                #29

                In MySql or MariaDB, most values of INPUT starting with an exclamation mark will cause a syntax error IF there is no space between your opening comment tag and INPUT, eg:

                SELECT * FROM test WHERE id= /*! oops */ 100

                However it's also possible to inject valid SQL that way:

                SELECT * FROM test WHERE ID= /*!0 OR ID > 0 OR ID= */ 100

                This query returning all rows in the table. See MySql ref: Comments[^] The idea is that you can then write SQL that works across DBMS, by including code that is only "seen" by MySql. You can also include query optimiser hints using a similar /*+ hint */ syntax, so you could probably break your query by starting INPUT with a plus sign as well, again only provided there's no space after the opening asterisk. And yes, this is definitely too much of a programming question to be in the Lounge! :laugh:

                1 Reply Last reply
                0
                • S Sandeep Mewara

                  � Forogar � wrote:

                  In which case the answer might be \0D --.

                  SELECT * FROM test WHERE id=/* \0D -- */100

                  still works.

                  Latest CodeProject post: Quick look into Machine Learning workflow How to solve Word Ladder Problem? To read all my blog posts, visit: Learn by Insight...

                  F Offline
                  F Offline
                  Forogar
                  wrote on last edited by
                  #30

                  I did say "might be". ;-)

                  - I would love to change the world, but they won’t give me the source code.

                  1 Reply Last reply
                  0
                  • S Sandeep Mewara

                    It breaks - gives unintended result. Throws an error or 0 results. For now, assume this query returns data.

                    Latest CodeProject post: Quick look into Machine Learning workflow How to solve Word Ladder Problem? To read all my blog posts, visit: Learn by Insight...

                    W Offline
                    W Offline
                    W Balboos GHB
                    wrote on last edited by
                    #31

                    Sandeep Mewara wrote:

                    0 results.

                    I don't think it's mere semantics but, in my opinion at least, returning 0 results is not throwing an error - the query ran and sent back an empty results set. This might be a way to trigger a great debate thread.

                    Ravings en masse^

                    "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                    "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

                    1 Reply Last reply
                    0
                    • S Sandeep Mewara

                      What could be the value of input such that below query fails?

                      SELECT * FROM test WHERE id= /* + INPUT + */ 100

                      PS: You cannot put * in the value anywhere.

                      Latest CodeProject post: Quick look into Machine Learning workflow How to solve Word Ladder Problem? To read all my blog posts, visit: Learn by Insight...

                      O Offline
                      O Offline
                      obermd
                      wrote on last edited by
                      #32

                      Won't a semi-colon (;) cause that comment to end?

                      P 1 Reply Last reply
                      0
                      • O obermd

                        Won't a semi-colon (;) cause that comment to end?

                        P Offline
                        P Offline
                        PIEBALDconsult
                        wrote on last edited by
                        #33

                        No.

                        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