[컴][리눅스] sudo group 에 계정 추가

자신의 계정의 sudo 가 되게 하는 법 / sudo가 안되는 이유 /

sudo group 에 계정 추가

자신의 계정의 sudo 가 안될때는 sudo group 에 user account 를 추가해주면 된다. 그리고 재로그인을 하자.

sudo usermod -a -G sudo <user-account>

gpasswd -a user_account group


group 에서 user 삭제

gpasswd -d user_account group


sudo 가 가능한 그룹 확인

vi /etc/sudoers

아래처럼 가능한 그룹을 확인할 수 있다.
...

%wheel  ALL=(ALL)   ALL

...


References

  1. sudo - How can I add a new user as sudoer using the command line? - Ask Ubuntu
  2. How do I remove a user from a group? - Unix & Linux Stack Exchange

[컴][리눅스] wtmp, utmpdump

로그관련  / 로그 / log / 리눅스 관리 로그 /


/var/log/wtmp

utmpdump 를 이용해서 최근의 접속 기록을 살펴볼 수 있다.
/var/log/wtmp 는 /etc/logrotate.conf 에 의해 일정기간, 일정 사이즈가 되면 wtmp.0 등으로 파일이 바뀐다.

# utmpdump /var/log/wtmp 

wtmp 의 의미

'w' 는 who 를 뜻한다. 'tmp' 는 temporary 에서 유래된 것이라 한다. 예전에 /tmp folder 에 있었기도 했고, file 자체가 주기적으로 교체되기 때문에 그렇다고 한다. 요즘은 timestamp 를 뜻하는 것이라고도 한다.


logrotate.conf

cat /etc/logrotate.conf


[컴][HDD] Degaussing (디가우징) 이후에 HDD 를 재사용할 수 있나?

하드디스크 디가우징후 다시 하드를 사용할 수 있나? / 하드 재사용 / 디가우징 하드 재사용


Degaussing 이후에 HDD 를 재사용할 수 있나?


요즘 디가우징(degaussing) 이 이슈이다. 그래서 관련해서 HDD 드라이브에 대해 좀 더 알아보기로 했다.

디가우징을 하면 데이터가 사라진다는 것은 알고 있다. 그럼 이 degaussing 을 한 HDD 를 다시 사용할 수 있을까??

degaussing tool 에 따라 다르다

결론은 degaussing tool 에 달려있다. degaussing 을 할 때 servo mark (또는 servo sector 라고 함) 를 지우느냐 그렇지 않느냐에 달려있다. ref. 3을 보면 servo mark 를 살리는 degaussing tool 도 존재하는 듯 하다.


servo mark, servo sector


그럼 이 servo sector 가 무엇이길래 이것에 따라 HDD 를 다시 사용할 수 있기도 하고 없기도 할까?

HDD 는 아래와 같이 만들어져 있다. 여기서 HDD 의 head arm 이 disk platter 위를 움직이면서 read/write 를 하게 된다. 이때 이 head arm 이 움직이는 길을 만들어주는 것이 servo sector 이다.
출처 : https://ayende.com/blog/174561/the-guts-n-glory-of-database-internals-managing-records

일단 HDD 를 구성하는 flatter 내부를 보자. 보다시피 servo mark 가 존재하고, servo mark 사이에 data 를 write 하게 된다.(좀 더 자세한 내용은 ref. 4를 참고하자)

ser




servowriter

servowriter 는 HDD 를 만드는 공장에서 platter 를 묶어서 HDD 로 만들기 전에 platter(raw media)위에 servo track 들을 그려준다.

그러니 만약 degaussing 으로 servo sector 가 사라졌다면, platter 를 빼서, servowriter 로 다시 servo sector 를 그려줘야 한다.


Servo(Servomechanism)

서보메카니즘은 "피드백 제어 시스템" 이다. ref. 1 의 설명에 나와 있지만, 자전거타기를 생각하면 이해하기 쉽다.

우리는 자전거를 타면서 넘어지지 않기 위해서 페달을 돌리고, 핸들을 좌우로 꺾는다. 그리고 돌부리가 보이면 핸들을 꺾어서 피하고, 다시 원위치로 돌아오는 등 상황에 따라서 자전거를 제어한다.

이렇게 상황(output) 에서 오는 결과(feedback) 을 보고, 다음 동작(input) 을 하는 것을 이야기한다.




References


  1. 서보 메커니즘 : 김상진
  2. Servowriter - Wikipedia
  3. Secure erase 9840 and 9940 data cartridges
  4. HDD from inside: Tracks and Zones. How hard it can be?
  5. 대통령 하드디스크도 통째 보관…근거없는 양승태 컴퓨터 '디가우징' - 노컷뉴스, 2018-06-28

[컴][linux] audit log

linux 에서 권한 부여 관련 log history / 행동 히스토리 / command history



Linux Auditing System

configuration

audit log path

  • /var/log/audit/audit.log
audit.log 는 아래와 같은 모양이다.
type=CRED_DISP msg=audit(1529285401.444:1738036): pid=11359 uid=0 auid=0 ses=238643 msg='op=PAM:setcred grantors=pam_env,pam_unix acct="root" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success'
type=USER_END msg=audit(1529285401.445:1738037): pid=11359 uid=0 auid=0 ses=238643 msg='op=PAM:session_close grantors=pam_loginuid,pam_keyinit,pam_limits,pam_systemd acct="root" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success'
type=CRED_DISP msg=audit(1529285401.453:1738038): pid=11360 uid=0 auid=0 ses=238644 msg='op=PAM:setcred grantors=pam_env,pam_unix acct="root" exe="/usr/sbin/crond" hostname=? addr=? terminal=cron res=success'
...

audit log 설명

----
type=USER_ACCT msg=audit(06/18/2018 10:12:35.793:1737897) : pid=6991 uid=cocktail auid=cocktail ses=234347 msg='op=PAM:accounting grantors=pam_unix,pam_localuser acct=root exe=/usr/bin/su hostname=cocktailfunding.com addr=? terminal=pts/0 res=success'
----
type=CRED_ACQ msg=audit(06/18/2018 10:12:35.793:1737898) : pid=6991 uid=cocktail auid=cocktail ses=234347 msg='op=PAM:setcred grantors=pam_unix acct=root exe=/usr/bin/su hostname=cocktailfunding.com addr=? terminal=pts/0 res=success'

audit log 에서 특정 내용만 검색


$>ausearch -ua 1000 -i -ts 06/17/2018

  • -ua 1000 
    • user ID, effective user ID, login user ID (auid) 가 1000 인 log 만 검색
    • user ID 는 process 를 실행한 account 를 이야기 한다. auid 는 login ID 이다. 누군가 'a' 라는 id 로 login 해서 sudo 로 실행을 하면 auid 는 'a' 가 되고, uid 는 root 가 될 것이다.
  • -i :  uid 숫자를 text account 로 interpret 해준다.
  • -ts : 시작시간 설정, 2018년 6월 17일
  • -te : 시작시간


See Also





[컴][php] php secure code 점검 tool

소스코드 검증 툴 / 검증 프로그램 / source code anaysis tool / secure code check / defective code 점검


PHP 안전 코드 분석 툴 PHP secure code anaysis tools

  1. Progpilot - Progpilot is a static analyzer tool for PHP that detects security vulnerabilities such as XSS and SQL Injection.
  2. RIPS
    1. RIPS is a static source code analyzer for vulnerabilities in PHP web applications. Please see notes on the sourceforge.net site.
    2. version 이 update 되면서, 상용으로 변경된듯 하다. 옛버전은 최신의 php 에 대한 지원을 하지 않는듯 하다.
  3. phpcs-security-audit - phpcs-security-audit is a set of PHP_CodeSniffer rules that finds flaws or weaknesses related to security in PHP and its popular CMS or frameworks. It currently has core PHP rules as well as Drupal 7 specific rules.
  4. VisualCodeGrepper (VCG)
    1. Scans C/C++, C#, VB, PHP, Java, and PL/SQL for security issues and for comments which may indicate defective code. The config files can be used to carry out additional checks for banned functions or functions which commonly cause security issues.
    2. windows 용이다. .msi 를 제공한다. 사용도 어렵지 않다.

See Also

  1. A reviewed list of useful PHP static analysis tools GitHub - exakat/php-static-analysis-tools
    • php 관련 tool 들의 링크를 모아놨다.
    • Bugs finders / Coding standards / DIY / Fixers / Metrics / SaaS / Misc

[컴][스크랩] 그래픽 관련 이야기

graphics /  그래픽 이론 / GTA 관련 그래픽


그래픽 관련 이야기



[컴] ffmpeg 으로 video 에서 audio format 변경하기

비디오에서 오디오 포맷 변경/ 오디오 타입 변경


ffmpeg download

  • ffmpeg 의 download 는 See Also . 1 을 확인하자.

Video 에서 audio format 변경하기

현재 video 에서 audio 의 format 을 바로 변경하는 법은 없는듯 하다. 대신에 다음2가지를 수행해주면 같은 효과를 얻을 수 있다.
  1. Video에서 audio 추출: 자신이 변환하고 싶은 format으로 추출하자.
  2. Video에 audio 더하기: video 에 audio 가 있어도 괜찮다. 그냥 덮어쓰게 된다.

Video에서 오디오 추출

video.mp4라는 video 파일의 오디오를 mp3 형식으로 추출할 때는 .mp3 로 적어주면 된다.

ffmpeg -i video.mp4 -vn -ab 256000 audio.mp3

aac 형식으로 추출하려면 간단히 aac 로 변경해 주면 된다.
ffmpeg -i video.mp4 -vn -ab 256000 audio.aac

Video 에 audio 더하기

ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -strict experimental -shortest output.mp4

-shortest  를 넣으면, 가장짧은 길이의 영상(shortest clip)이 끝날때마다 인코딩(encoding)을 수행한다.

소요시간

내 경우에 audio.acc 를 이용해서 위의 명령을 실행했다. 2시간짜리 영상의 경우 대략 6분정도가 소요됐다.(cpu i3-2100, 3.1GHz)

See Also

  1. fmpeg 으로 video container 변경

References

  1. Useful FFmpeg Commands For Converting Audio & Video Files