m0bilesecurity / RMS-Runtime-Mobile-Security

Runtime Mobile Security (RMS) 📱🔥 - is a powerful web interface that helps you to manipulate Android and iOS Apps at Runtime
https://twitter.com/mobilesecurity_
GNU General Public License v3.0
2.58k stars 373 forks source link

API Output decide codes #59

Closed ghost closed 3 years ago

ghost commented 3 years ago

This is small code snippet from my side( I learner, don't know more about js ). So please add it in upcoming version release of RMS ( I am personally tested, it working well )

Q ) What it does ? Ans: API Output will be gives in the form of string or bytes, based on ascii value compare it gives output

Bytes2String function bin2String(array){ var result = ""; for(var i = 0; i < array.length; ++i){ result+= (String.fromCharCode(array[i])); } return result; }

Ascii check from string function isAsciiOnly(str) { for (var i = 0; i < str.length; i++) if (str.charCodeAt(i) > 127) return false; return true; }

Giving output based on ascii value (string or bytes) function printType(str){ var check = bin2String(str); if(isAsciiOnly(check) == true){ return bin2String(str); } else { return str; } }

API Monitor (Now output print type decides based on ascii value compare from string, if ascii is false then output in bytes, otherwise it's in string ) if (callback) { var calledFrom = Exception.$new().getStackTrace().toString().split(',')[1]; var to_print = { category: category, class: clazz, method: method, args: args ? printType(args[0]) : "N/A", returnValue: retval ? printType(retval) : "N/A", calledFrom: calledFrom }; retval = callback(retval, to_print); }

m0bilesecurity commented 3 years ago

Hey @j311yfish, many thanks for this good addition! Do you have time to directly open a Pull Request?

I'll be happy to test and merge your code in the next RMS release 🎉🎉🎉

ghost commented 3 years ago

Yeah, i'll do