system-calls

How to hook system calls of my android app (non rooted device)

百般思念 提交于 2019-12-03 06:35:07
I am trying to intercept all system calls made by my Android app on a non rooted device. So every time my app writes/reads a file, I want to intercept the system call and encrypt/decrypt the stream for security purposes. The encryption part is no problem, but how do I intercept the system calls? Because parts of the app are modules developed by third party providers of which I can not change the source code, there is no other way to make sure that data is stored securely. Since I do not have root access I cannot access the address of the system call table as described here and I can not do

Get CPU usage of a device running Android 8 Oreo

别等时光非礼了梦想. 提交于 2019-12-03 06:15:29
I'm really confused. I have just noticed that starting from Android 8 all system calls like /proc/stat will be disabled. Ok, but what is work around to get CPU Usage in Android 8? No system calls at all. Is there some API that I'm not familiar with? I really hope that there is solution which I can't see now. No, all of /proc/stat has been disabled for non-System apps, as a side-channel. More information, with an official response from Google here: https://issuetracker.google.com/issues/37140047 来源: https://stackoverflow.com/questions/46182041/get-cpu-usage-of-a-device-running-android-8-oreo

How to Dynamically Allocate Memory Using Assembly and System Calls Under Linux

柔情痞子 提交于 2019-12-03 05:44:01
问题 I'm looking for some good code examples of dynamic memory allocation using an assembly language under Linux and using system calls, not malloc and friends. What are some of the simplest but effective ways to do this? On Intel 386+ computers. 回答1: brk(2). And take a look at ELF. 回答2: On Linux mmap2 is a sensible system call to use for this at a low level. It takes 6 arguments, so in IA32 you can call it using: mov eax, 192 ; mmap2 xor ebx, ebx ; addr = NULL mov ecx, 4096 ; len = 4096 mov edx,

How to set ulimit -n from a golang program?

柔情痞子 提交于 2019-12-03 05:23:53
问题 My purspose was to set ulimit -n from within a golang program so that I do not have to set it globally but restrict it within the program. Found systemcalls setrlimit and get rlimit for the same. (http://linux.die.net/man/2/setrlimit) But when I tried a sample program for the same I was getting an error saying invalid argument while setting the value. package main import ( "fmt" "syscall" ) func main() { var rLimit syscall.Rlimit err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit) if err

System calls on Windows

别来无恙 提交于 2019-12-03 05:10:46
问题 I just want to ask, I know that standart system calls in Linux are done by int instruction pointing into Interrupt Vector Table. I assume this is similiar on Windows. But, how do you call some higher-level specific system routines? Such as how do you tell Windows to create a window? I know this is handled by the code in the dll, but what actually happend at assembler-instruction level? Does the routine in dll calls software interrupt by int instruction, or is there any different approach to

How to interpret strace output?

旧街凉风 提交于 2019-12-03 01:58:34
问题 I need to profile the performance of an application for which I am using strace. However, I do not really know how to interpret the various system calls the strace emits. Examples of a few of them are below: (A) lseek(3, 1600, SEEK_SET) = 1600 (B) write(3, "G_DATA 300 0 "..., 800) = 800 (C) close(3) = 0 (D) mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b600b179000 (E) munmap(0x2b600b179000, 4096) = 0 (F) fstat(3, {st_mode=S_IFREG|0644, st_size=1600, ...}) = 0 I

How to trace a process for system calls?

北战南征 提交于 2019-12-03 00:41:25
I am trying to code a program that traces itself for system calls. I am having a difficult time making this work. I tried calling a fork() to create an instance of itself (the code), then monitor the resulting child process. The goal is for the parent process to return the index of every system call made by the child process and output it to the screen. Somehow it is not working as planned. Here is the code: #include <unistd.h> /* for read(), write(), close(), fork() */ #include <fcntl.h> /* for open() */ #include <stdio.h> #include <sys/ptrace.h> #include <sys/reg.h> #include <sys/wait.h>

Trap all accesses to an address range (Linux)

心已入冬 提交于 2019-12-03 00:23:11
Background I'm writing a framework to enable co-simulation of RTL running in a simulator and un-modified host software. The host software is written to control actual hardware and typically works in one of two ways: Read/Write calls through a driver Memory mapped access using mmap The former case is pretty straightforward - write a library that implements the same read / write calls as the driver and link against that when running a simulation. This all works wonderfully and I can run un-modified production software as stimulus for my RTL simulations. The second case is turning out to be far

c and LD_PRELOAD. open and open64 calls intercepted, but not stat64

徘徊边缘 提交于 2019-12-03 00:01:55
I've done a little shared library that tries to intercept open, open64, stat and stat64 sys calls. When I export LD_PRELOAD and run oracle's sqlplus, I can see the traces of the open and open64 calls, but no traces of the stat and stat64 calls. The shared library is a single c file with all the definitions of the sys calls in it. Why does it happen that some syscalls are intercepted and others don't? thanks for your help. Because the GNU libc implements open() and open64() as you'd expect (i.e. they're just dynamically linked symbols that you can hook into with LD_PRELOAD ), but does something

C++ gettid() was not declared in this scope

二次信任 提交于 2019-12-02 20:57:06
A simple program is: I would like to get the thread ID of both of the threads using this gettid function. I do not want to do the sysCall directly. I want to use this function. #include <iostream> #include <boost/thread/thread.hpp> #include <boost/date_time/date.hpp> #include <unistd.h> #include <sys/types.h> using namespace boost; using namespace std; boost::thread thread_obj; boost::thread thread_obj1; void func(void) { char x; cout << "enter y to interrupt" << endl; cin >> x; pid_t tid = gettid(); cout << "tid:" << tid << endl; if (x == 'y') { cout << "x = 'y'" << endl; cout << "thread