300x250
320x100
스크립트 짤때마다 소소한 기능들을 검색해서 만드는데 맨날 비슷한 로직을 맨날 찾으니까 뭔가 너무 비효율적이다.
낙서장으로 써야겠다.
1. 입력 값 내에 특정 배열의 요소들이 포함되어 있는지 검증
var array = ['su', 'frida'];
var string = '/bin/su/frida/finfinfinfinfinfinfrida/sususu//sususususu';
if (array.some(element => string.includes(element))) {
console.log('All elements of the array are contained in the string.');
} else {
console.log('Not all elements of the array are contained in the string.');
}
2. 정규표현식을 이용한 입력값 내 모든 문자열에 대하여 치환
var tmp_str = args_.readCString();
tmp_str = tmp_str.replace(/frida|su|magisk|sbin|xbin|.ext|.core|\/su|status/gi, 'live');
3. 문자열을 아스키 형태로 변환, 문자열을 헥스 형태로 변환
// aa -> "41 41" 형태로 변환
function pattern_Converter(search_Keyword) {
var tmp_Buffer = ""
for (var i = 0; i<search_Keyword.length; i++){
var string_to_ascii = search_Keyword[i].charCodeAt(0);
var ascii_to_hex = string_to_ascii.toString(16);
tmp_Buffer += ascii_to_hex;
}
var tmp_Buffer2 = tmp_Buffer.replace(/(.{2})/g,"$1 ");
return tmp_Buffer2
}
// aa -> [0x41,0x41] 형태로 변환
function pattern_Converter_writeByteArray(convert_Keyword) {
var tmp_Array = new Array();
for(var i = 0; i<convert_Keyword.length; i++){
tmp_Array[i] = "0x"+convert_Keyword[i].charCodeAt(0).toString(16);
}
return tmp_Array;
}
728x90
320x100
'Development' 카테고리의 다른 글
[Javascript] 자바스크립트에 대한 고찰 (1) | 2023.01.14 |
---|---|
[ChatGPT] AI로 구현할 기능을 편하게 검색하자. (0) | 2022.12.08 |
IntelliJ 단축키 (0) | 2022.11.09 |