본문 바로가기

bash7

HTML 코드에서 데이터 추출하여 JSON 형식 변환 HTML 코드에서 데이터를 추출하여 JSON 형식으로 변환하는 작업을 수행합니다. 이를 간소화하려면 정규 표현식을 사용하는 대신 더 구조화된 방법을 사용하는 것이 좋습니다. 다음은 Python을 사용하여 같은 작업을 수행하는 방법입니다. Python은 정규 표현식 대신 BeautifulSoup과 같은 라이브러리를 사용하여 HTML 파싱을 더 쉽게 할 수 있습니다. from bs4 import BeautifulSoup import re import json html = """ 여기에 HTML 코드를 입력하세요 """ soup = BeautifulSoup(html, 'html.parser') data = [] for row in soup.find_all('tr'): # 'tr' 태그를 포함하는 모든 행을 찾.. 2023. 9. 23.
Bourne Again Shell (Bash) 임의코드 실행 취약점 보안 업데이트 개요리눅스 계열 등 운영체제에서 사용중인 GNU Bash에서 발생하는 임의코드 실행 취약점 (CVE-2014-6271) 보안 업데이트를 우회하여 악용할 수 있는 취약점 발생 (CVE-2014-7169)공격자는 해당 취약점이 존재하는 시스템을 대상으로 원격에서 악의적인 시스템 명령을 실행시킬 수 있으므로 해결방안에 따라 보안 업데이트 적용 권고 해당 시스템영향 받는 시스템GNU Bash를 사용하는 시스템 해결방안해당 취약점에 대한 보안업데이트가 공개된 OS를 운영하고 있을 경우, 참고사이트의 내용을 참조하여 보안업데이트 수행CentOS [1]Debian [2]Redhat [3]Ubuntu [4] 용어 정리Shell : 사용자가 입력한 문장을 해석하여 시스템 기능을 수행하는 명령어 해석기 기타 문의사항한국인.. 2014. 9. 26.
Bash Vulnerability Code Injection Attack bash_ld_preload.c#include #include #include static void __attribute__ ((constructor)) strip_env(void); extern char **environ; static void strip_env() { char *p,*c; int i = 0; for (p = environ[i]; p!=NULL;i++ ) { c = strstr(p,"=() {"); if (c != NULL) { *(c+2) = '\0'; } p = environ[i]; } } Compile it:gcc bash_ld_preload.c -fPIC -shared -Wl,-soname,bash_ld_preload.so.1 -o bash_ld_preload.so Copy ba.. 2014. 9. 25.
Bash Script: How read file line by line (best and worst way) Input: $ cat sample.txt This is sample file This is normal text file Source: $ cat readfile.sh #!/bin/bash i=1; FILE=sample.txt # Wrong way to read the file. # This may cause problem, check the value of 'i' at the end of the loopecho "###############################" cat $FILE | while read line; do echo "Line # $i: $line" ((i++)) done echo "Total number of lines in file: $i" # The worst way to r.. 2014. 9. 19.
Bash: Pass Shell Variables To awk How do I pass shell variables to awk command or script under UNIX like operating systems? The -v option can be used to pass shell variables to awk command. Consider the following simple example, root="/webroot" echo | awk -v r=$root '{ print "shell root value - " r}' In this example search file using awk as follows: #!/bin/bash # Usage : Search word using awk for given file. # Syntax: ./script ".. 2012. 7. 18.