How to pass password to decode LZMA (7zip) encrypted archive in C / Objective-C? - objective-c

Does anyone know how to pass password to decode function in LZMA SDK?

Looking at the sources and another thread here, I'm guessing it will be good to start looking at where and how the sha256* functions are defined and used. The documentation appears minimal to nothing, so the code should be your major guide along with your knowledge of cryptography.

Related

Where are the passhash9 algorithm from?

I am using the Botan library which contains an algorithm named Passhash9.
It is a Password Hashing. Now, I want to know where it is from.
who can give me some papers or links about it?
Passhash9: https://botan.randombit.net/doxygen/dir_2f2a81ce70eadda327392ced4f630ceb.html
Proverbially too late to answer. I had the same question too until I looked into the source code. I don't know why they named it that way. But apparently passhash9 is PBKDF2 (source).

How to detect if a function called fopen or not?

I'm trying to write a pam backdoor scanner, which may call fopen function in pam_sm_authenticate(normal file will not call fopen in this function) to store username and password, but I can't use external command such as "nm, readelf" or something like that, so the only way seems to scan pam_sm_authenticate function and find all call instructions and caculate the address to check if it is calling fopen, but it is too troublesome and i'm not very familiar with ELF file(I even dont know how to find offset of pam_sm_authenticate, I'm useing dlopen and dlsym to get the address..), so I wonder if there is a better or easy way to detect it? Thankyou.
TL;DR: building a robust "pam backdoor scanner" is theoretically impossible, so you should give up now and think about other ways to solve your problem.
Your question is very confusing, but I think what you are asking is: "can I determine programmatically whether pam_sm_authenticate calls fopen".
That is the wrong question to ask, for several reasons:
if pam_sm_authenticate calls foo, and foo calls fopen, then you still have a problem, so you really should be scanning pam_sm_authenticate and every function it calls (recursively),
the fopen is far from the only way to write files: you could also use open, or system (as in system("echo $secret > /tmp/backdoor"), or direct sys_open syscall, or a multitude of other hacks.
finally, the pam_sm_authenticate can use just-in-time compilation techniques to build arbitrary code (including code calling fopen) at runtime, and answering whether it does by examining its code is equivalent to solving the halting problem (i.e. impossible).

Reading Byte Data through the serial port in C++/CLI

I am trying to make an interface with another program so I have to use C++.
It's been years since I have programmed in C++ and I have been at this problem for about a week so I'm slowly starting to see how everything works.
I want to read byte data coming from a serial port device.
I have verified that I can get text through the serial port using the readline command:
For example:
String^ message = _serialPort->Readline();
Is how the data is read in an example from MSDN that I got to work successfully.
However I have tried to modify it several times and I'm having no luck coming up with something that reads the data as bytes. (I already have conversion of byte data to string so I can actually see the bytes such as the number 15 equaling 0f in bytes.)
Modifying the code to
wchar_t message = _serialPort->Readline();
gives me
error c2440: 'initializing' : cannot convert from System::String ^' to 'wchar_t'.
I'm not familiar with Readline. Is it only for strings? I have verified that it does work with strings and if I use a serial device that sends a string the first set of code does work.
Can someone explain what method I could use to read byte data? Thanks.
If you actually want to use C++ rather than C++/CLI, I recommend using boost.asio. It is well established, relatively easy to understand, and has a specific set of functionality just for working with serial ports.
Update
Pure C++ Win32 API versions:
See the following good references
CodeProject article
MSDN
Is there any specific reason you are doing this in C++/CLI code?
I thought you might not even be aware of that (otherwise, tag your questions, please).
String^, Readline etc are CLR functions (i.e. .NET, think: "you could do this more easily in C#). So, again,
If there is a need for this to be in C++, why don't you look at the native Win32 API
Otherwise, why are you bothering with C++
If you really wanted C++/CLI I suggest not mixing native/managed code when handling the serial IO. You can get an UnmanagedMemoryStream to marshal the data in/out of managed land.
$0.02

Weird function names in Quartz Core: what gives?

Out of curiosity, what may the rationale behind these function names (found in Apple's Quartz Core framework) be?
ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv()
ZNK2CA6Render9Animation9next_timeEdRd()
ZN2CA11GenericRectIiE5insetEii()
Do you think the developers somehow encoded argument types in function names? How do you find yourself putting "EP19" in there in the course of day-to-day coding? In what circumstances do such barely readable function names actually help you read code and otherwise be more productive?
Thanks in advance for any hints, and Merry Christmas!
These 'mangled' names are automatically generated by the C++ compiler and indeed encode type information.

API for getting IL from byte array

There is a GetILAsByteArray method in MethodBody class which gives body of a method. I am looking for converting this byte array into more understandable IL instructions (into a List or something like that). What resources, open source code or api available are there to help me understand and convert this byte array (or do it for me)?
I found this but it does not work with generics. I am pretty much looking for guidance to convert understand these bytes in all framework versions.
CLI Documentation is also helpful for learning IL instructions but I cannot see how to use it to make these bytes make sense.
I just wrote an extension method to get a more understandable list of instructions using GetILAsByteArray. It's quite simple, the API is like:
public static IList<Instruction> GetInstructions (this MethodBase self);
You can read more about the implementation in my blog post. Or you can go take the implementation and start using it.
Have a look at the Mono.Cecil library.
It is a huge undertaking. I wrote the starts of an IL reader and it had a pretty good amount of opcodes implemented: but you will need to finish it.
http://svn.ensemble-os.org/tags/OldOCJ/CIL/
There is also MONO Cecil, which is feature-complete.