ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
This is in reference to a blind sql injection attack example, where the sql statement is trying to determine if the first character of the database user is less than or equal to the letter B.
Code:
if (ascii(substring(user,1,1))<=66) waitfor delay '00:00:15'
If you're talking about converting ASCII numbers to binary, why not:
Code:
input &= 0xdf; // optional for small letters
input -= 0x30;
if(input > 15) { input -= 7; }
I don't see any point to converting ASCII other values to binary. SPACE is 0x20, the value is "the value", what conversion would you do to that? Same thing for ASCII G, that is 0x47, what does G represent otherwise though? Meanwhile things like AF could be HEX AF which are ASCII { 0x41, 0x46 }, or in binary as decimal values they could be { A, F } or { 10, 15 }.
The other issue is what language? Because strictly C is one thing, and yes there are library functions, there are also very many library functions for C++, or C#, or Objective-C, or Java, ...
My example is me thinking from the perspective the code running without library support, no OS.
That is what I'm after. Is there a way to work it out, say like convert ip address to binary and vice versa?
thanks
Paste them into a web app that does the conversion?
BTW, your "that's what I'm after" is completely different from what you were asking up until now. If you're trying to steer the answers by strategically omitting information, you should know that never works.
That is what I'm after. Is there a way to work it out, say like convert ip address to binary and vice versa?
thanks
Missed this from earlier. I thought that was already in the inet library. For instance the sin_addr_t or addr_t structures I forget and not bothering to look it up, but one version requires a long which means you need it in binary, and another version takes is in w.x.y.z form. I recall something like inet_ntoa() and stuff like that. Just searching for example network code and viewing different examples will show these conversions or how to use a version that starts with an ASCII IP address and accepts it in that form. And I may be wrong about it being inet, if you just look at the various include files you need to add to do networking, it's in one or more of those include files.
Of course most modern system use UFT-8 encoding, not ASCII. So there are several different ways to represent, e.g., "B"
And your proposed test, even in an ASCII world, would not accomplish your stated goal. A test for N < 66 would accept a "B" and anything that followed B in the ASCII code table.
If you're really in an ASCII world, and the computer language you're using permits it, consider just using 'B' to represent 'B', and ignore the binary (or decimal, or ...) equivalents to that symbol. (I.e., What's the point in switching from one encoding scheme to some other one if the meaning of the symbol is all you care about?)
BTW, your "that's what I'm after" is completely different from what you were asking up until now. If you're trying to steer the answers by strategically omitting information, you should know that never works.
I'm not trying to omit any information, it my lack of experience and understanding of the topic, which is why I'm not able to ask the question clearly.
At one time you were new to learning something too, so you probably weren't sure how to go about asking the right question either.
My first question would be like some of the others, what language?
One of the examples I'm seeing online pertain to using SQL, like the following:
Code:
1 and
(
select top 1 ascii(lower(substring(name, 1, 1))) from sysobjects where id=(
select top 1 id from (
select top 1 id from sysobjects where xtype='u' order by id
) sq order by id desc
)
) > 109
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.