728x90

"System.getProperty()" 사용법

자바를 실행할 때, 실행되는 곳의 정보를 얻어오거나 운영체제의 정보가 필요할 때가 있습니다.
실행 위치에 있는 파일을 읽어드려야 하는데, 현재 위치를 알 수 있는 방법 등 시스템의 정보를 가져올때  System.getProperty() 를 사용합니다.

 

System.getProperty() 으로 괄호 안에 주어진 특정 문자를 적어넣으면 그 값이 String 으로 출력됩니다.

String dir = System.getProperty("user.home");
System.out.println(dir);


// 리눅스 인 경우 /home/유저명/
// macOS인 경우 //Users/유저명/

 

Property 주요 검색어

검색어
java.version Java 버전
java.vendor Java 공급자
java.vendor.url Java 공급자 주소
java.home Java를 설치한 디렉토리
java.class.version Java 클래스 버전
java.class.path Java 클래스 경로
java.ext.dir 확장기능의 클래스 경로
os.name 운영체제 이름
os.arch 운영체제 아키텍처
os.version 운영체제 버전 정보
file.separator 파일 구분 문자
path.separator 경로 구분 문자
line.separator 행 구분 문자
user.name 사용자 계정
user.home 사용자 홈 디렉토리
user.dir

현재 디렉토리

property 확인 메소드해보기

import java.util.Properties;
import java.util.Enumeration;

public class Test {
    public static void main(String[] args) {
        Properties props = System.getProperties();
        for(Enumeration en = props.propertyNames(); en.hasMoreElements();) {
            String key = (String)en.nextElement();
            String value = props.getProperty(key);
            System.out.println(key + "=" + value);
        }
    }

}

 

전혀 없는 키 만들기

전혀 없는 키값인데, System.getProperty("file.location.env"); 라면서 사용하는 경우가 있습니다.

이럴경우, JVM 의 VM arguments 부분을 살펴보면 다음과 같이 세팅되어 있다.

System.getProperty("file.location.env"); 

를 사용하기 위해서 JVM 의 VM arguments 부분에 설정해 주세요.

-Dfile.location.env="./fileUploads/"

 

JVM의 VM arguments 는 JVM을 구동할때, 필요한 여러가지 값을 세팅하는 것인데 -D하고 바로뒤에 키="값"을 세팅하면

프로그램내에서 System.getProperty("키"); 를 통해 값을 가져올 수 있습니다.

 

ava.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition
sun.boot.library.path=C:\Program Files\Java\jdk1.5.0_18\jre\bin
java.vm.version=1.5.0_18-b02
java.vm.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
path.separator=;
java.vm.name=Java HotSpot(TM) Client VM
file.encoding.pkg=sun.io
user.country=KR
sun.java.launcher=SUN_STANDARD
sun.os.patch.level=Service Pack 3
java.vm.specification.name=Java Virtual Machine Specification
user.dir=C:\java\client

java.runtime.version=1.5.0_18-b02
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs=C:\Program Files\Java\jdk1.5.0_18\jre\lib\endorsed
os.arch=x86
java.io.tmpdir=C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\
line.separator=

java.vm.specification.vendor=Sun Microsystems Inc.
user.variant=
os.name=Windows XP
sun.jnu.encoding=MS949
java.library.path=C:\Program Files\Java\jdk1.5.0_18\bin;

java.specification.name=Java Platform API Specification
java.class.version=49.0
sun.management.compiler=HotSpot Client Compiler
os.version=5.1
user.home=C:\Documents and Settings\Administrator
user.timezone=
java.awt.printerjob=sun.awt.windows.WPrinterJob
file.encoding=MS949
java.specification.version=1.5
user.name=Administrator
java.vm.specification.version=1.0
sun.arch.data.model=32
java.home=C:\Program Files\Java\jdk1.5.0_18\jre
java.specification.vendor=Sun Microsystems Inc.
user.language=ko
awt.toolkit=sun.awt.windows.WToolkit
java.vm.info=mixed mode, sharing
java.version=1.5.0_18
file.separator=\
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeLittle
sun.desktop=windows
sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86

 

출처: https://unabated.tistory.com/entry/Java에서-SystemgetProperty [랄라라]

728x90

MacOS 에서 시스템 폴더에 접근하여 파일을 생성하거나 디렉토리를 만들려고 하니 "Operation not permitted" 라는 메세지가 뜨면서 실행이 안됩니다.

 

 

MacOS 에서 시스템 폴더에 접근하여 파일을 생성하거나 디렉토리를 만들려고 하면  "Operation not permitted" 라는 메세지가 뜨면서 실행이 안됩니다.

저의 경우에는 Apache 웹서버에 특정 파일을 가져다 놓을려고 했는데 위와 같은 에러가 발생하면서 생성이 되지 않았습니다.

이럴 경우에는 SIP (Security Integrity Protection)라고 하는 시스템 무결성 보호(SIP)를 꺼주어야 합니다.

 

시스템 무결성 보호(SIP)란 macOS 시스템 폴더 내에 시스템을 구동하는데 큰 영향을 끼치는 파일들을 보호하기 위해 존재하며, 해당 파일들은 admin 계정으로 접속을 하더라도 수정, 실행, 삭제 등의 제약을 받습니다.

 

즉, 시스템 파일과 폴더를 수정할 가능성을 사전에 차단해 악성 소프트웨어로부터 Mac을 보호해주는 기능입니다.
매우 효과적인 보안기능이지만 사용자가 시스템을 수정하거나 일부 소프트웨어를 사용해야 할 경우에 SIP를 해제해야 합니다.

따라서, 평소에는 SIP 기능이 활성화된 상태로 맥을 사용하며, 필요에 따라 잠깐씩 해제하는 것이 보안 관점에서 바람직합니다

 

 

SIP에 영향으로 내 마음대로 수정/삭제가 불가능한 디렉토리

/System
/sbin
/bin
/usr : /usr/local 디렉토리를 제외한 나머지 서브디렉토리
/Applications : macOS에 기본적으로 설치된 앱(캘린더, 사진, 사파리, 터미널 등


 

SIP기능 비활성하기

1. Mac 재부팅하여 command + R 키를 계속 눌러 Recovery Mode 로 진입합니다.
2. Recovery Mode 에서 Utilities 메뉴에서 Terminal 을 클릭합니다.
3. Terminal 화면에서 "csrutil disable"을 입력합니다.
4. "reboot"을 입력하여 재부팅합니다.

 

 

Recovery Mode (복구모드)에 들어가면 보여지는 화면입니다.

 

$ csrtuil disable

....

$ reboot

위와 같이 하면 재부팅되면서 SIP기능 비활성화 됩니다.


그리고 나서 /usr 나 /etc 에 cp 명령을 해보면 

Read-only file system 

와 같은 에러가 발생합니다.

$ sudo cp libphp5.so /usr/libexec/apache2/
Password:
cp: /usr/libexec/apache2/libphp5.so: Read-only file system

 

그래서 부팅이 되면 터미널에서 다음 커맨드를 입력하여 / 에 대해서도 쓰기가 가능하도록 조치해야 합니다.

$ sudo mount -uw /

이제 / 디렉토리가 쓰기가능하게 바뀌면서 파일을 만들거나 디렉토리를 만들어 줄 수 있게 됩니다.

 

macOS의 시스템 폴더에 대한 권한을 획득하여 작업을 하신 후에 다시 활성화하는게 좋습니다.


SIP기능 활성화하기 - macOS Sierra 10.12.2 이전 버전
1. Mac 재부팅하여 command + R 키를 계속 눌러 Recovery Mode 로 진입합니다.
2. Recovery Mode 에서 Utilities 메뉴에서 Terminal 을 클릭합니다.
3. Terminal 화면에서 "csrutil enable"을 입력합니다.
4. "reboot"을 입력하여 재부팅합니다.

$ csrutil enable

...

$ reboot

 

 

SIP기능 활성화하기 - macOS Sierra 10.12.2 이후 버전

macOS Sierra 10.12.2 이후 버전에서 복구모드로 접근할 필요 없이, 터미널에서 아래 커맨드만 치시면 됩니다.

$ sudo csrutil clear

또는 

$ sudo /usr/bin/csrutil clear

 

< 참조URL >

Mac OS X Operation not Permitted 발생시
https://ellordnet.tistory.com/65
https://luv2irene.tistory.com/12
시스템 무결성 보호(SIP) 상태 해제 및 활성화하는 방법
https://macinjune.com/all-posts/mac/tip/%EC%8B%9C%EC%8A%A4%ED%85%9C-%EB%AC%B4%EA%B2%B0%EC%84%B1-%EB%B3%B4%ED%98%B8sip-%EC%83%81%ED%83%9C-%ED%95%B4%EC%A0%9C-%ED%99%9C%EC%84%B1%ED%99%94-%EB%B0%A9%EB%B2%95/
macOS - Catalina / (root) 에 디렉토리 만들기
https://junho85.pe.kr/1458
728x90

원문을 보고 정리하였습니다.

https://macpaw.com/how-to/remove-anysearch-malware-from-mac

 

How to get rid of Any Search Manager on your Mac

Any Search Manager is a piece of malware that bundles itself with downloads and redirects your browser’s homepage. Here’s how to remove it.

macpaw.com

해당 블로그에서는 아래의 클리너를 추천하고 있습니다.

하지만 무료 평가판이라고 하지만 결국 바이러스 search 하고 나서 발견되어 치료할려고 하면 업그레이드를 유도합니다.

https://macpaw.com/ko/download/cleanmymac

 

CleanMyMac X 평가판 무료 다운로드 — Mac을 위한 스마트한 컴퓨터 클리너

CleanMyMac X를 무려로 내려받으세요. CleanMyMac X는 Mac을 청소하고 보호하며 성능을 올려주는 필수 유틸리티입니다. 매일 사용하여 수 GB의 여유 공간을 확보하고, 악성코드를 제거하며, macOS의 건강상태를 확인하세요. 지금 MacBook이나 iMac에 내려받아 직접 확인해보세요!

macpaw.com

Combo Cleaner 도 사용해봤는데 AntiVirus를 검색하니 3건이 나오네요.

그런데 그런데 역시나 Upgrade to Premium 으로 비용내고 업그레이드 받아서 삭제하라고 뜨네요.

 

Variant.Application.MAC.Adload.8

Variant.Adware.Mac.AdLoad.1

 

해당 파일을 찾아봤는데 전혀 못찾겠어요.

 

 

아래 수동 방식으로 삭제처리하고 나서 다시 CleanMyMac을 돌렸더니 CleanMyMac 에서는 나오지 않네요.


위의 클리너를 사용하지 않고 수동으로 할 수 있는 방법이 있으니 참고하시길 바랍니다.

 


핵심은 Launch Agents 와 Daemons 폴더에 의심되는 프로그램을 삭제해야 합니다.

그치만 해당 폴더에 들어가면 ".plist" 파일이 안보일 수 있습니다.

 

결국 terminal.app (터미널)로 들어가서 보시는게 더 좋습니다.

자 시작합니다.


1. /Libaray/LaunchAgents 살펴보기 

저 같은 경우에는 

cd /Libaray/LaunchAgents 로 이동하여  의심되는 파일을 삭제하였습니다.

 

2. 사용자 의 LaunchAgents 를 살펴보기 

root 의 LaunchAgents 를 살펴보고 의심되는 plist파일을 삭제하였습니다.

그 다음  사용자 의 LaunchAgents 를 살펴봐야 합니다.

 

"jaehonghan" 이라는 사용자 폴더의 Libaray 에서 똑같은 LaunchAgents 폴더를 살펴 봅니다.

다행히도 여기에는 의심되는 내용이 없네요.

 

 

 

 

 

3. 사용자 의 ~/Library/Application\ Support/ 살펴보기 

사용자의 어플레케이션 서포트 폴더로 가서 의심되는 프로그램이 설치되어 있는지 살펴봐야 합니다.

 

cd ~/Library/Application\ Support/

 

저 같은 경우에는 UltraSearchSystem 을 발견하여 삭제하였습니다.

 

4. 구글 브라우저의 설정에서 검색엔진 점검하기

구글 브라우저에서 chrome://settings 로 주소검색을 합니다.

검색엔진이 다른 것으로 변경된게 아니지 확인해봐야 합니다.

저의 경우에는 UltraSearch 라는 엔진으로 변경되어 있었습니다.

그래서 이를 Google검색엔진으로 다시 변경해줬습니다.

 

아래와 같이 검색엔진쪽으로 가보니 이상한 검색엔진이 선택되어 있었습니다.

해서 해당 선택엔진을 Google로 바꿔주기 위해서 "검색엔진 관리" 메뉴로 들어가서 Google을 제외하고 다 지웠습니다

 

저의 경우에는 기본 검색엔진에 Google, yahoo,  naver  가 존재했지만 Google을 빼고 삭제했습니다.

 

Google로 검색엔진을 바꾼 후의 화면입니다.

 

5. 구글 브라우저의 권한이 다른 프로그램에게도 줬는지 확인하기

구글 브라우저에서 chrome://policy 로 주소검색을 합니다.

구글 부라우저가 자신의 권한을 다른 프로그램에게도 줬는지를 파악하기 위해서 입니다.

 

 

 

다행히도 저의 경우에는 다른 프로그램에 넘어가지 않았어요.

하지만 위에서 언급했듯이 다른 프로그램에 구글이 자신의 권한을 넘겨주는 경우가 있기 때문에 꼭 찾아서 삭제해야 한다고 하네요.

 

6. 구글 브라우저에 대해 제대로 설정되어 있는지를 확인하기

defaults read com.google.Chrome

위의 명령어를 command line 에서 직접 타이핑 하시면 

{

    LastRunAppBundlePath = "/Applications/Google Chrome.app";

}

와 같이 뜨는지 확인해 보시길 바랍니다.

 


정  리

 

 

1. 관리자 폴더에 들어가서 의심되는 파일을 삭제합니다.

$ cd /Library/LaunchAgents/

$ cd /Library/LaunchDaemons/

 

2. 사용자 폴더에 들어가서 의심되는 파일을 삭제합니다.

$ cd ~/Library/LaunchAgents/

$ cd ~/Library/LaunchDaemons/

 

3. 어플리케이션 suppert파일로 가서 의심되는 파일을 삭제합니다.

$ cd ~/Library/Application\ Support/

 

4. Chrome 브라우저의 검색엔진중 원하시는 검색엔진을 선택하신 후에 다른 검색엔진은 삭제합니다.

구글 브라우저에서 chrome://settings 로 주소검색을 합니다.

검색엔진이 다른 것으로 변경된게 아니지 확인해봐야 합니다.

저의 경우에는 UltraSearch 라는 엔진으로 변경되어 있었습니다.

그래서 이를 Google검색엔진으로 다시 변경해줬습니다.

 

5. 구글 브라우저의 권한이 다른 프로그램에게도 줬는지 확인하기

구글 브라우저에서 chrome://policy 로 주소검색을 합니다.

구글 부라우저가 자신의 권한을 다른 프로그램에게도 줬는지를 파악하기 위해서 입니다.

 

6. 구글 브라우저에 대해 제대로 설정되어 있는지를 확인합니다.

$ defaults read com.google.Chrome

위의 명령어를 command line 에서 직접 타이핑 하시면 

{

    LastRunAppBundlePath = "/Applications/Google Chrome.app";

}

와 같이 뜨는지 확인해 보시길 바랍니다.

 


아래는 원문 입니다.

확인 해보시기 바랍니다.

 

How do I know if my Mac is infected?

When you launch a web browser like Safari, Chrome, or Firefox you will not see your regular homepage. Instead, you’ll see the Any Search page. You will then need to uninstall Any Search from your Mac, using the steps below.


How did I get infected?

When you give permission to the seemingly legitimate download to be installed, the bundled hijacker gets permission too. That’s why you should always be certain of what you’re downloading and double-check the website you’ve downloaded it from before you give permission for anything to be installed. Fortunately, it’s not too difficult to remove.

 

How to remove Any Search from your Mac

1. Go to the Apple menu and click on System Preferences

2. Look for a pane called Profiles. If it’s there, it will be next to Accessibility

3. If it’s there, click on it and look to see if there is a profile called AdminPrefs

4. If it’s there, unlock System Preferences by clicking the padlock and entering your login details, if necessary

5. Click on the AdminPrefs profile and click the ‘-‘ button at the bottom left of the window

 

Check your Startup items

Malware like the Any Search Manager virus sometimes inserts itself in your startup items so it launches every time you boot your Mac.

1. Go to System Preferences again and click the Users & Groups pane.

2. Unlock it using the padlock, then click on your user name in the left-hand pane.

3. Choose the Login items tab in the main window.

4. Look for anything that seems suspicious.

5. If you find anything, click on it then click the ‘-‘ button at the bottom of the window to remove it.

Alternatively, there is an easier way to remove login items, using CleanMyMac, which scans your Mac for startup processes and allows you to remove them with one click. CleanMyMac also allows you to quickly and easily remove browser extensions, uninstall apps, and reclaim tens of gigabytes of disk space.

 

Get CleanMyMac here. It's a free version that allows you to remove a few login items completely for free.

 

Remove Launch Agents and Daemons

1. In the Finder, click on the Go menu and choose Go to Folder.

 

2. Type /Library/LaunchDaemons

3. Scan the list of .plist files and look for anything with a name you don’t recognize.

4. If you find one, click on it and preview the file, looking for the name of a vendor you recognize.

5. If you don’t find one, drag the file to the Trash.

6. Repeat steps 1-5 for /Library/LaunchAgents and
~/Library/LaunchAgents

7. Once you’ve dragged all the files you want to remove to the Trash, empty it and restart your Mac.

 

Reset the default page in browser

How to remove Any Search from Safari

1. Once your Mac has restarted, launch Safari

2. Click on the Safari menu and then choose Preferences

3. Click on the Search tab and choose the search engine you want to use

4. Select the General tab and set the Homepage to your preferred home page and the options above it to your preference from the menu options

 

How to remove Any Search from Chrome

1. Launch Chrome.

2. Click the Settings menu icon (three horizontal lines) on the left of the window or type chrome://settings/  into the address bar.

3. Click On start-up and check the button next to “Open a specific page or set of pages”.

4. Click on the More icon (three vertical dots).

5. Choose Edit and type or paste the URL you want as your start-up page into the text box.

6. Click Save.

7. Click on the Settings icon again.

8. Choose Search Engine.

9. Click Manage search engines and press the More button next to the Any Search engine, then select Remove from list.

 

10. Click on the dropdown menu next to the “Search engine used in the address bar” and choose the search engine you want to use. Alternatively, click Manage search engines and either add one from the bigger list (by clicking on the More icon and choosing Make Default) or press Add and type in the URL of another search engine.

 

 

How to remove AnySearch from Firefox

1. Launch Firefox.

2. Press the settings button (three horizontal lines) on the right-hand side of the toolbar, or type about:preferences into the address bar.

3. Click the Home category and next to “Homepage and new windows” click on the dropdown menu and choose either Firefox Home or Custom URL. If you choose the Custom URL type the URL you want to open into the text box.

4. Click the Search category and in the main window, scroll down to “One-Click Search Engines”. Click on Any Search and press Remove.

5. Scroll back up and click on the menu under the Default Search engine and choose the one you want.

 

Remove suspicious browser extensions

 

The final steps for removal [Important]

So far we've cleaned the browser part — what's left is it to root out AnySearch from your system parts associated with Chrome and other browsers. First, we will need to check if AnySearch has seized your Chrome settings. 

 

 

STEP 1

Please open Chrome, paste this string into the URL field and press Return: chrome://policy/

You will see something like this:


See the Level and Policy value columns. What's written there?

"Recommended" means AnySearch has gained control over your Chrome settings — need to uninstall Chrome.

"Mandatory" means the malware is sitting deeper and is tied to your user account
— go to step 2 below.

For additional check:

Go to Applications/Terminal
Open Terminal, paste the following command and press Return:
defaults read com.google.Chrome

Now, look through the results. If you see anything related to Anysearch there, you can simply uninstall Chrome and reinstall it anew. The best way to uninstall Chrome along with all leftovers is CleanMyMac's Uninstaller tool.


STEP 2

If that is not the case, please open Finder, go up to the Go menu in the menubar -> Go to Folder, and paste this directory:
/Library/Managed Preferences/[your username]

You should enter [your username] as shown in System Preferences/Users & Groups

Open the folder. Now look for a “com.google.Chrome” file there. 

If you have found it in any of these locations, please open the file in any editor and check if you can find any Anysearch-related information there. Then, manually remove the info from the file and restart your computer.

The same logic applies to Firefox and Safari browsers. 

 

+ Recent posts