QCacheGrind source code path wrong - xdebug

Trying to profile my code with QCacheGrind and everything loads fine but I can't see the source code inside the program.
For some reason the source code path is wrong.
Right now it is cachegrind file location + php file location
It should be only php file location

This is a cachegrind bug that appears under non-linux filesystems.
Cachegrind will look for source files in the path where your callgrind output file is, appended to the path where your Source file is (this path is stored in the callgrind output).
C:/callgrind/C:/Project/src/index.php
You can work around this bug by placing your callgrind outputs in a folder directly outside your source root ( C:/Project/ ). And running a replace on your callgrind output file to delete the directory of your callgrind output from all of the source file paths, thus the callgrind output will show that your source file is at src/index.php .
In the end, cachegrind will join C:/Project/ and src/index.php and you will be able to view your source code in cachegrind.

Related

Gzip Files: Extracting Does Not Work as Expected

I'm facing this very strange problem when working with gzip files. I'm trying to download this file https://www.sec.gov/Archives/edgar/daily-index/2014/QTR2/master.20140402.idx.gz
When I view the contents of the file inside the archive, it is perfect.
However when I unzip the contents and try to see them, it is all gibberish.
Is something wrong with the file or am I missing to see anything here?
If I remember correctly, an idx file is a Java file. It can also a plain text archive format, which it is in this case.
On Linux, try running
gunzip master.20140402.idx.gz
This will extract it into an idx file, which you should be able to open with any text reader, such as vi, since vi can open pretty much anything.
On Windows, you can, from the command line, use WinZip, with:
wzunzip -d master.20140402.idx.gz
You can then use something like IE, Edge, or Wordpad to try to examine the file, that should automagically load a readable environment.
EDIT:
So, I downloaded the file, and was able to extract, and view it in vi, IE, and Wordpad, using my above commands, so if you are seeing gibberish, try redownloading it. It should be 104kb in .gz format, and 533 kb extracted.

Code Injection in .png file

I am using the libpng- a c library to check the valid .png file. If a file is valid it passes the test. I want to inject shell code in it. How can I craft a .png file, so that it is still a valid image file and also contains some shell code in it. Please tell me how is it possible. Thanks.
Well, AFAIK there is no way to inject code into a png file and execute it. But you can inject your png file into a shell script, and after view it. But you must convince the one you hack to make the png file executable and to open so-called png file through terminal.
The procedure is:
Create a text file, call it executeme.png
Paste the following code into it, note that there shouldn't be any new line at the end of the file.
#!/bin/bash
PNG_FILE=$(mktemp /tmp/hack.XXXXXXX.png)
ARCHIVE=$(awk '/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0; }' $0)
tail -n+$ARCHIVE $0 > "$PNG_FILE"
# whatever you want to do is here!
xdg-open $PNG_FILE
exit 0
__ARCHIVE_BELOW__
Append your original png file using cat injectme.png >> executeme.png.
Make executeme.png executable.
If you run the executeme.png from terminal, the original png file will be shown using the default image viewer, and your injected code will be run.
Note: I don't believe there is someone so stupid to execute that file.
Note2: On Ubuntu, executeme.png cannot be executed from file managers because it's tried to be opened using the file manager due to the png extension. You may rename file executeme.png to execute.\rpng (append a carriage return before png after dot) so at first it looks like a png file, since its extension is not png it will be executed with double click if it's executable. To make that renaming, you may need to use terminal.
Have a good time hacking! :D
Further reading: Linux journal, making installers

Loading files into MAGMA

I'm trying to load files into MAGMA and am running into some trouble. Ostensibly, the command load "filename";should be sufficient. I've attempted, but keep getting the same result:
>> load "filename";
^
User error: Could not open file "filename" (No such file or directory)
The file is saved in my documents folder, so I'm not sure what the issue is. Do I have to specify the path? Save the file in a particular place?
I've tried reformatting, using both txt and rtf files, so I don't think that's the issue.
For loading file in MAGMA you can place your file in installed place folder. For example: C:\Program Files (x86)\Magma
Also if your file have an special format you should mention it.
Suppose You want loading a txt file with name a. with load"a"; you face with error. You must type load"a.txt";.
Try using GetCurrentDirectory() command to find your current directory location. And then you can use SetPath() to change where MAGMA has to be to search for your file. This will fix it.

How do I write a java code that will export a file to a usb drive

It is exactly wnat the title says I have beenlooking for quite sometime and haven't found anything the main use would be as a auto run file to collect error reports from our offic computers
You could do this if you run the program from the USB drive itself, and declare wherever the file is stored as the "working directory" as the USB may have different IDs for different computers...things get messy.
My recommendation is to use File in Java, and Path (http://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html)
A warning though is that if you copy a directory (folder), the files within that folder are actually not automatically copied...its just the way it works. (more here: http://docs.oracle.com/javase/tutorial/essential/io/copy.html)
Assuming the file is always in the same place going to the same place. For example:
Files.copy(source, destination, options);
or you can open text file and read from it for a more advanced method:
Files.copy(InputStream, path, options);
etc.

How to get full path of a file just by giving the filename in C?

Suppose I have a file path as C:\Sample\example.txt.
how can full path of the file be retrieved (the file can be in any directory) just by giving the filename i.e., example.txt in C ?
get the source for the "find" command from the (i think) gnu package (or a linux source distribution), and copy the appropriate passages for you platform.

Resources