Exploitable | Django application full of security holes | TLS library
kandi X-RAY | Exploitable Summary
kandi X-RAY | Exploitable Summary
A Django application full of security holes for instructional purposes.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Exploitable
Exploitable Key Features
Exploitable Examples and Code Snippets
Community Discussions
Trending Discussions on Exploitable
QUESTION
Years ago a teacher once said to class that 'everything that gets parsed through the CPU can also be exploited'.
Back then I didn't know too much about the topic, but now the statement is nagging on me and I lack the correct vocabulary to find an answer to this question in the internet myself, so I kindly ask you for help.
We had the lesson about 'cat', 'grep' and 'less' and she said that in the worst case even those commands can cause harm if we parse the wrong content through it.
I don't really understand how she meant that. I do know how CPU registers work, we also had to write an educational buffer overflow so I have seen assembly code in the registers aswell. I still don't get the following:
- How do commands get executed in the CPU at all? e.g. I use 'cat' so somehwere there will be a call of the command. But how does the data I enter get parsed to the CPU? If I 'cat' a .txt file which contains 'hello world' - can I find that string in HEX somewhere in the CPU registers? And if yes:
- How does the CPU know that said string is NOT to be executed?
- Could you think of any scencario where the above commands could get exploited? Afaik only text gets parsed through it, how could that be exploitable? What do I have to be careful about?
Thanks alot!
...ANSWER
Answered 2021-Apr-19 at 07:05Machine code executes by being fetched by the instruction-fetch part of the CPU, at the address pointed to by RIP, the instruction-pointer. CPUs can only execute machine code from memory.
General-purpose registers get loaded with data from data load/store instructions, like mov eax, [rdi]
. Having data in registers is totally unrelated to having it execute as machine code. Remember that RIP is a pointer, not actual machine-code bytes. (RIP can be set with jump instructions, including indirect jump to copy a GP register into it, or ret
to pop the stack into it).
It would help to learn some basics of assembly language, because you seem to be missing some key concepts there. It's kind of hard to answer the security part of this question when the entire premise seems to be built on some misunderstanding of how computers work. (Which I don't think I can easily clear up here without writing a book on assembly language.) All I can really do is point you at CPU-architecture stuff that answers part of the title question of how instructions get executed. (Not from registers).
Related:
How does a computer distinguish between Data and Instructions?
Modern Microprocessors A 90-Minute Guide! covers the basic fetch/decode/execute cycle of simple pipelines. Modern CPUs might have more complex internals, but from a correctness / security POV are equivalent. (Except for exploits like Spectre and Meltdown that depend on speculative execution).
https://www.realworldtech.com/sandy-bridge/3/ is a deep-dive on Intel's Sandybridge microarchitecture. That page covering instruction-fetch shows how things really work under the hood in real CPUs. (AMD Zen is fairly similar.)
You keep using the word "parse", but I think you just mean "pass". You don't "parse content through" something, but you can "pass content through". Anyway no, cat
usually doesn't involve copying or looking-at data in user-space, unless you run cat -n
to add line numbers.
See Race condition when piping through x86-64 assembly program for an x86-64 Linux asm implementation of plain cat
using read
and write
system calls. Nothing in it is data-dependent, except for the command-line arg. The data being copied is never loaded into CPU registers in user-space.
Inside the kernel, copy_to_user
inside Linux's implementation of a read()
system call on x86-64 will normally use rep movsb
for the copy, not a loop with separate load/store, so even in kernel the data gets copied from the page-cache, pipe buffer, or whatever, to user-space without actually being in a register. (Same for write
copying it to whatever stdout is connected to.)
Other commands, like less
and grep
, would load data into registers, but that doesn't directly introduce any risk of it being executed as code.
QUESTION
C# string's Splice method seems to copy remnants into an array of strings instead of just reading them. Is there a c++17 string_view equivalent to bypass copying?
For those not familiar with string_view, here is some background information.
The string_view family of template specializations provides an efficient way to pass a read-only, exception-safe, non-owning handle to the character data of any string-like objects with the first element of the sequence at position zero. (...)
From Microsoft's C++ Team Blog std::string_view: The Duct Tape of String Types:
string_view solves the “every platform and library has its own string type” problem for parameters. It can bind to any sequence of characters, so you can just write your function as accepting a string view:
...
ANSWER
Answered 2021-Apr-01 at 04:03ReadOnlySpan
could work.
Have a look at All About Span: Exploring a New .NET Mainstay
A second variant of Span, called System.ReadOnlySpan, enables read-only access. This type is just like Span, except its indexer takes advantage of a new C# 7.2 feature to return a “ref readonly T” instead of a “ref T,” enabling it to work with immutable data types like System.String. ReadOnlySpan makes it very efficient to slice strings without allocating or copying, as shown here:
QUESTION
I need to enter part of a file name (myTestFiles) And I need to retrieve (myTestFiles_20210305.txt) For now I am recovering (C: \ folder1 \ folder2 \ myTestFiles_20210305.txt)
For the moment with my order I get the name of the file AND THE PATH, which I do not want.
I just want to get the name of the file. and why not the path but on two different exploitable variables.
I am a beginner on this language and on the forums that I have used I only saw what I already had ...
Thank you
Code:
...ANSWER
Answered 2021-Mar-05 at 11:30If you want the file name from the path, use Path.GetFileName method:
https://docs.microsoft.com/en-us/dotnet/api/system.io.path.getfilename?view=net-5.0
Example code from documentation:
QUESTION
I have exploitable c
code which takes user input. I am able to print out contents of the stack using %10$p
which prints out the 10th value stored on the stack. However when I try to run the same program but with %10$n
it segfaults. Which does not make sense. Segfaults means I am trying to access memory that does not belong to me. However, this memory does 'belong to me' since I can print it out. Why does this happen?
Unfortunately, I cannot postcode for it because it is for an assignment. So I have to keep this question abstract.
...ANSWER
Answered 2020-Nov-07 at 02:45%10$n
means write the number of characters printed to the address pointed to by the 10th element on the stack, not the actual 10th element of the stack. This means that if the 10th element doesn't point to valid, writable memory, which it likely doesn't, then you will segfault upon trying to write to it.
QUESTION
There is an existing question "Average of 3 long integers" that is specifically concerned with the efficient computation of the average of three signed integers.
The use of unsigned integers however allows for additional optimizations not applicable to the scenario covered in the previous question. This question is about the efficient computation of the average of three unsigned integers, where the average is rounded towards zero, i.e. in mathematical terms I want to compute ⌊ (a + b + c) / 3 ⌋.
A straightforward way to compute this average is
...ANSWER
Answered 2020-Oct-28 at 06:12I suspect SIMPLE is defeating the throughput benchmark by CSEing and hoisting a/3+b/3
and a%3+b%3
out of the loop, reusing those results for all 16 avg0..15
results.
(The SIMPLE version can hoist much more of the work than the tricky version; really just a ^ b
and a & b
in that version.)
Forcing the function to not inline introduces more front-end overhead, but does make your version win, as we expect it should on a CPU with deep out-of-order execution buffers to overlap independent work. There's lots of ILP to find across iterations, for the throughput benchmark. (I didn't look closely at the asm for the non-inline version.)
https://godbolt.org/z/j95qn3 (using __attribute__((noinline))
with clang -O3 -march=skylake
on Godbolt's SKX CPUs) shows 2.58 nanosec throughput for the simple way, 2.48 nanosec throughput for your way. vs. 1.17 nanosec throughput with inlining for the simple version.
-march=skylake
allows mulx
for more flexible full-multiply, but otherwise no benefit from BMI2. andn
isn't used; the line you commented with mulhi / andn
is mulx
into RCX / and rcx, -2
which only requires a sign-extended immediate.
Another way to do this without forcing call/ret overhead would be inline asm like in Preventing compiler optimizations while benchmarking (Chandler Carruth's CppCon talk has some example of how he uses a couple wrappers), or Google Benchmark's benchmark::DoNotOptimize
.
Specifically, GNU C asm("" : "+r"(a), "+r"(b))
between each avgX = average_of_3 (a, b, avgX);
statement will make the compiler forget everything it knows about the values of a
and b
, while keeping them in registers.
My answer on I don't understand the definition of DoNotOptimizeAway goes into more detail about using a read-only "r"
register constraint to force the compiler to materialize a result in a register, vs. "+r"
to make it assume the value has been modified.
If you understand GNU C inline asm well, it may be easier to roll your own in ways that you know exactly what they do.
QUESTION
I have a set of EURUSD data and looking at arbitrage opportunities. The data is formatted as shown in photo.
mispricing_1=yes
when buy_b_sell_A>0
and mispricing_2=yes
when buy_A_sell_B>0
In the photo there is no datapoint where exploitable=yes
however when the buy_b_sell_A>6
or when buy_A_sell_B>6
, then we get exploitable=yes
I am looking to calculate the average length of time an exploitable arbitrage opportunity is present, shown by exploitable=yes
How can I calculate the length of time that there are consecutive exploitable=yes
so that I can plot a distribution and then also calculate the average?
ANSWER
Answered 2020-Jul-18 at 10:35If you import this as a panda frame, which lets call it df, you can do df.groupby[‘exploitable’].mean You could do .histogram or something for distribution.
QUESTION
I try to write my first CTF program which should be exploitable to Buffer-Overflow. In order to do that, I did the next simple steps:
- Created a
main
function - Initialized two local variables -
is_authorized
(char of size 1) andpassword
(array of size 128) - Disabled debug runtime checks - no canaries should be at the stack
So main
look like this:
ANSWER
Answered 2020-Jul-16 at 10:36the variables should be one after another on the stack
No, there is no such rule. Compiler should do anything, as long as side effects stay. A good compiler with optimizations should remove both variables from your code.
What are these weird bytes? The only thought I have in mind is the protection mechanism, but I disabled this, then what else it could be?
Padding between variables allocated on stack. Your non-optimizing compiler allocates stack variables aligned to an address divisible by 4. Hence 3 bytes padding between the next char
variable. The values of the bytes are most probably left-over garbage left on stack by program initialization routines.
QUESTION
I'm new to Software security and I'm studying it now at the university. I had some doubts about the Format String exploit, in particular how to count the length (in number of bytes) of a format string exploit.
Suppose that I have the following vulnerable code:
...ANSWER
Answered 2020-Jul-06 at 19:46\x15\x45\x41\x42\x17\x45\x41\x42%16940c%7$hn%563c%8$hn
does indeed refer to a sequence of 30 chars/bytes. snprintf (s.usr, 31, "%s", user);
would therefore be needed to copy it.[1] The extra count is because snprintf
reserves a space for a NUL.
Since you need s.usr
to be the start of a sequence of 30 characters, and you can only place 15 of the necessary characters there, your exploit can't work as-is.
This doesn't mean that the bug can't be exploited. It may be possible to write a shorter exploit that jumps to the remaining exploit located somewhere else, e.g. in user
.[2] But I don't have the necessary knowledge to asses the feasibility of this.
- Of course, you would also need a larger area in
s.usr
, at least under normal circumstances. user
would contain<15-byte exploit>
. The 15-byte exploit would jump to the remainder of the exploit.
QUESTION
I'm working on an authorization API that my company would like to use both internally and as an external API for some of our customers. We'd prefer to not have to whitelist every domain from which a request might originate, but that seems to be the default behavior web browsers are designed to enforce when the withCredentials
option of an XHR is true
.
We can work around this problem by having our API return whatever the Origin
header of a request contains as the value of the Access-Control-Allow-Origin
header of the API's response, but that apparently is what's supposedly so dangerous, so I'm not sure we should be doing this. Maybe in our situation it's perfectly safe, but not understanding the nature of the potential attack, I can't yet say.
According to this article:
https://portswigger.net/research/exploiting-cors-misconfigurations-for-bitcoins-and-bounties
...this kind of CORS behavior was exploitable enough that the author could easily have stolen other people's bitcoins from a bitcoin exchange.
But how? For me, the article doesn't make that clear.
Is there some other vulnerability beyond the CORS issue that is needed? Looking at the examples, the PDF of a slide presentation that goes with the article, and a referenced article at http://ejj.io/misconfigured-cors/, I'm not fully understanding where access to some other user's info or credentials slips into the picture.
In the diagram above, it looks to me like "evil.com" would somehow have to be tricking a user into giving evil.com their bitcoin exchange credentials first, before CORS enters the picture, and if evil.com can do that already, wouldn't the CORS issue only make an already very bad situation just a little worse?
I'm sure that it can't be that simple, or no one would be raising the alarm about a fully open origin policy, but I can't figure out what I'm missing here.
Is there something where, say, just having one browser page opened to evil.com, while a user is also visiting their bitcoin exchange, allows cookie data to be passed over to evil.com? Seems like that would also be a big problem too, CORS or no CORS.
...ANSWER
Answered 2019-Nov-05 at 18:11I finally figured out where the risk is, and I had to figure it out for myself. Maybe all the people explaining this CORS exploit think that their readers will automatically know what's going on with cookies in a situation like this, and don't think it's even worth mentioning.
It certainly would have helped me if they'd mentioned it, however!
What I understand now is this:
- You set up an API on myservice.com that allows CORS access, it lets anyone from any domain in, and it responds to XHR requests where
withCredentials
istrue
with the host's origin reflected back in theAccess-Control-Accept-Origin
header, rather than sending back*
. - A user on mylegitapicustomer.com, which legitimately uses myservice.com, logs into your API, and gets back a session cookie that belongs to the myservice.com domain.
- That user, using the same web browser, then visits evilhacker.com.
- If the webpage from evilhacker.com issues an XHR request to myservice.com, all of the cookies that belong to the myservice.com domain go along for the ride!
- Your website at myservice.com sees the session cookie it issued to the legit user who had visited via mylegitapicustomer.com and happily responds to the above request by making any requested changes to the user's account, or responds with any info about the user requested.
- evilhacker.com can now receive any of this info, and/or perform any API actions, that legit access via mylegitapicustomer.com would have allowed.
QUESTION
I am currently using datastudio to transform my data into reporting and I had problems in creation because the data available is not very exploitable. I would like to clean them through the regexp functions but I can't find the right expression
Exemple :
...ANSWER
Answered 2020-Apr-09 at 11:30It looks like you want everything after the first "- ". For this use instr()
and substr()
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Exploitable
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page