This seems to be right everywgere But I am getting IndexError everytime at the bin_bash line. but with the...












-1














#!/usr/bin/env python
import pwn
import re

gdb_puts = 0x7ffff7a649c0
gdb_system = 0x7ffff7a33440

offset = gdb_puts - gdb_system

elf = pwn.ELF('./vuln')
p = elf.process()

prompt = p.recv()
print prompt

puts = re.findall('puts: (.*)', prompt)[0]
bin_bash = re.findall('useful_string: (.*)', prompt)[0]

print puts
print bin_bash


This gives me



Traceback (most recent call last):
File "ape.py", line 17, in <module>
bin_bash = re.findall('useful_string: (.*)', prompt)[0]
IndexError: list index out of range









share|improve this question




















  • 1




    It's because your regex doesn't match. As there is no sample data in your question, we can't tell you much more.
    – Thierry Lathuille
    Nov 18 '18 at 13:34










  • What does just re.findall('useful_string: (.*)', prompt) return? If it's nothing, then you probably have a regex problem.
    – connectyourcharger
    Nov 18 '18 at 13:35










  • The field "Title" is for a short title only. A full explanation goes in the much larger field.
    – usr2564301
    Nov 18 '18 at 13:44
















-1














#!/usr/bin/env python
import pwn
import re

gdb_puts = 0x7ffff7a649c0
gdb_system = 0x7ffff7a33440

offset = gdb_puts - gdb_system

elf = pwn.ELF('./vuln')
p = elf.process()

prompt = p.recv()
print prompt

puts = re.findall('puts: (.*)', prompt)[0]
bin_bash = re.findall('useful_string: (.*)', prompt)[0]

print puts
print bin_bash


This gives me



Traceback (most recent call last):
File "ape.py", line 17, in <module>
bin_bash = re.findall('useful_string: (.*)', prompt)[0]
IndexError: list index out of range









share|improve this question




















  • 1




    It's because your regex doesn't match. As there is no sample data in your question, we can't tell you much more.
    – Thierry Lathuille
    Nov 18 '18 at 13:34










  • What does just re.findall('useful_string: (.*)', prompt) return? If it's nothing, then you probably have a regex problem.
    – connectyourcharger
    Nov 18 '18 at 13:35










  • The field "Title" is for a short title only. A full explanation goes in the much larger field.
    – usr2564301
    Nov 18 '18 at 13:44














-1












-1








-1







#!/usr/bin/env python
import pwn
import re

gdb_puts = 0x7ffff7a649c0
gdb_system = 0x7ffff7a33440

offset = gdb_puts - gdb_system

elf = pwn.ELF('./vuln')
p = elf.process()

prompt = p.recv()
print prompt

puts = re.findall('puts: (.*)', prompt)[0]
bin_bash = re.findall('useful_string: (.*)', prompt)[0]

print puts
print bin_bash


This gives me



Traceback (most recent call last):
File "ape.py", line 17, in <module>
bin_bash = re.findall('useful_string: (.*)', prompt)[0]
IndexError: list index out of range









share|improve this question















#!/usr/bin/env python
import pwn
import re

gdb_puts = 0x7ffff7a649c0
gdb_system = 0x7ffff7a33440

offset = gdb_puts - gdb_system

elf = pwn.ELF('./vuln')
p = elf.process()

prompt = p.recv()
print prompt

puts = re.findall('puts: (.*)', prompt)[0]
bin_bash = re.findall('useful_string: (.*)', prompt)[0]

print puts
print bin_bash


This gives me



Traceback (most recent call last):
File "ape.py", line 17, in <module>
bin_bash = re.findall('useful_string: (.*)', prompt)[0]
IndexError: list index out of range






python binary buffer-overflow index-error






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 18 '18 at 13:32









timgeb

50.4k116391




50.4k116391










asked Nov 18 '18 at 13:32









AshutoshAshutosh

13




13








  • 1




    It's because your regex doesn't match. As there is no sample data in your question, we can't tell you much more.
    – Thierry Lathuille
    Nov 18 '18 at 13:34










  • What does just re.findall('useful_string: (.*)', prompt) return? If it's nothing, then you probably have a regex problem.
    – connectyourcharger
    Nov 18 '18 at 13:35










  • The field "Title" is for a short title only. A full explanation goes in the much larger field.
    – usr2564301
    Nov 18 '18 at 13:44














  • 1




    It's because your regex doesn't match. As there is no sample data in your question, we can't tell you much more.
    – Thierry Lathuille
    Nov 18 '18 at 13:34










  • What does just re.findall('useful_string: (.*)', prompt) return? If it's nothing, then you probably have a regex problem.
    – connectyourcharger
    Nov 18 '18 at 13:35










  • The field "Title" is for a short title only. A full explanation goes in the much larger field.
    – usr2564301
    Nov 18 '18 at 13:44








1




1




It's because your regex doesn't match. As there is no sample data in your question, we can't tell you much more.
– Thierry Lathuille
Nov 18 '18 at 13:34




It's because your regex doesn't match. As there is no sample data in your question, we can't tell you much more.
– Thierry Lathuille
Nov 18 '18 at 13:34












What does just re.findall('useful_string: (.*)', prompt) return? If it's nothing, then you probably have a regex problem.
– connectyourcharger
Nov 18 '18 at 13:35




What does just re.findall('useful_string: (.*)', prompt) return? If it's nothing, then you probably have a regex problem.
– connectyourcharger
Nov 18 '18 at 13:35












The field "Title" is for a short title only. A full explanation goes in the much larger field.
– usr2564301
Nov 18 '18 at 13:44




The field "Title" is for a short title only. A full explanation goes in the much larger field.
– usr2564301
Nov 18 '18 at 13:44












1 Answer
1






active

oldest

votes


















0














If you get a list index out of range on [0] then the list is empty, and contains no value. You can check if a list has any values in it using not, e.g.:



my_list = function_that_returns_a_list()
if not my_list:
print("Your list is empty")
else:
print(my_list[0])


Verify that your re.findall('useful_string: (.*)', prompt) isn't returning an empty list.






share|improve this answer























  • You're probably right I've a C code and compiled binary file in the same directory which has "useful_string" let me add my C code so you can have a better look at it.
    – Ashutosh
    Nov 19 '18 at 14:17










  • I'm attaching the google drive link //drive.google.com/open?id=1srPd4dhrwUkhtUPzr5FtW-ikU2ULAeQ7
    – Ashutosh
    Nov 19 '18 at 14:23










  • I don't know C well enough to see what data that will parse to your Python script. You'll have to make a different question with different tags - I've answered this one as best I can.
    – Moralous
    Nov 19 '18 at 21:06











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53361418%2fthis-seems-to-be-right-everywgere-but-i-am-getting-indexerror-everytime-at-the-b%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














If you get a list index out of range on [0] then the list is empty, and contains no value. You can check if a list has any values in it using not, e.g.:



my_list = function_that_returns_a_list()
if not my_list:
print("Your list is empty")
else:
print(my_list[0])


Verify that your re.findall('useful_string: (.*)', prompt) isn't returning an empty list.






share|improve this answer























  • You're probably right I've a C code and compiled binary file in the same directory which has "useful_string" let me add my C code so you can have a better look at it.
    – Ashutosh
    Nov 19 '18 at 14:17










  • I'm attaching the google drive link //drive.google.com/open?id=1srPd4dhrwUkhtUPzr5FtW-ikU2ULAeQ7
    – Ashutosh
    Nov 19 '18 at 14:23










  • I don't know C well enough to see what data that will parse to your Python script. You'll have to make a different question with different tags - I've answered this one as best I can.
    – Moralous
    Nov 19 '18 at 21:06
















0














If you get a list index out of range on [0] then the list is empty, and contains no value. You can check if a list has any values in it using not, e.g.:



my_list = function_that_returns_a_list()
if not my_list:
print("Your list is empty")
else:
print(my_list[0])


Verify that your re.findall('useful_string: (.*)', prompt) isn't returning an empty list.






share|improve this answer























  • You're probably right I've a C code and compiled binary file in the same directory which has "useful_string" let me add my C code so you can have a better look at it.
    – Ashutosh
    Nov 19 '18 at 14:17










  • I'm attaching the google drive link //drive.google.com/open?id=1srPd4dhrwUkhtUPzr5FtW-ikU2ULAeQ7
    – Ashutosh
    Nov 19 '18 at 14:23










  • I don't know C well enough to see what data that will parse to your Python script. You'll have to make a different question with different tags - I've answered this one as best I can.
    – Moralous
    Nov 19 '18 at 21:06














0












0








0






If you get a list index out of range on [0] then the list is empty, and contains no value. You can check if a list has any values in it using not, e.g.:



my_list = function_that_returns_a_list()
if not my_list:
print("Your list is empty")
else:
print(my_list[0])


Verify that your re.findall('useful_string: (.*)', prompt) isn't returning an empty list.






share|improve this answer














If you get a list index out of range on [0] then the list is empty, and contains no value. You can check if a list has any values in it using not, e.g.:



my_list = function_that_returns_a_list()
if not my_list:
print("Your list is empty")
else:
print(my_list[0])


Verify that your re.findall('useful_string: (.*)', prompt) isn't returning an empty list.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 18 '18 at 13:40

























answered Nov 18 '18 at 13:36









MoralousMoralous

71111




71111












  • You're probably right I've a C code and compiled binary file in the same directory which has "useful_string" let me add my C code so you can have a better look at it.
    – Ashutosh
    Nov 19 '18 at 14:17










  • I'm attaching the google drive link //drive.google.com/open?id=1srPd4dhrwUkhtUPzr5FtW-ikU2ULAeQ7
    – Ashutosh
    Nov 19 '18 at 14:23










  • I don't know C well enough to see what data that will parse to your Python script. You'll have to make a different question with different tags - I've answered this one as best I can.
    – Moralous
    Nov 19 '18 at 21:06


















  • You're probably right I've a C code and compiled binary file in the same directory which has "useful_string" let me add my C code so you can have a better look at it.
    – Ashutosh
    Nov 19 '18 at 14:17










  • I'm attaching the google drive link //drive.google.com/open?id=1srPd4dhrwUkhtUPzr5FtW-ikU2ULAeQ7
    – Ashutosh
    Nov 19 '18 at 14:23










  • I don't know C well enough to see what data that will parse to your Python script. You'll have to make a different question with different tags - I've answered this one as best I can.
    – Moralous
    Nov 19 '18 at 21:06
















You're probably right I've a C code and compiled binary file in the same directory which has "useful_string" let me add my C code so you can have a better look at it.
– Ashutosh
Nov 19 '18 at 14:17




You're probably right I've a C code and compiled binary file in the same directory which has "useful_string" let me add my C code so you can have a better look at it.
– Ashutosh
Nov 19 '18 at 14:17












I'm attaching the google drive link //drive.google.com/open?id=1srPd4dhrwUkhtUPzr5FtW-ikU2ULAeQ7
– Ashutosh
Nov 19 '18 at 14:23




I'm attaching the google drive link //drive.google.com/open?id=1srPd4dhrwUkhtUPzr5FtW-ikU2ULAeQ7
– Ashutosh
Nov 19 '18 at 14:23












I don't know C well enough to see what data that will parse to your Python script. You'll have to make a different question with different tags - I've answered this one as best I can.
– Moralous
Nov 19 '18 at 21:06




I don't know C well enough to see what data that will parse to your Python script. You'll have to make a different question with different tags - I've answered this one as best I can.
– Moralous
Nov 19 '18 at 21:06


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53361418%2fthis-seems-to-be-right-everywgere-but-i-am-getting-indexerror-everytime-at-the-b%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?