레이블이 개발인 게시물을 표시합니다. 모든 게시물 표시
레이블이 개발인 게시물을 표시합니다. 모든 게시물 표시

2021년 12월 22일 수요일

[Win] 포트확인 netstat

netstat를 이용하여 사용중인 포트, 연결된 주소, 연결 상태등을 알수 있다.


netstat /na


특정 포트가 사용중인지 확인도 가능하다

netstat /na | find "443"


관리자 권한이 있을 시 관련 프로세스 정보도 알수 있다

netstat /nab 


내용이 많아 보기 힘들때는 파일로 만들어서 확인할 수 있다.

netstat /nab > portinfo.txt


2021년 12월 9일 목요일

[Win] UUID 얻기( wmic 이용 )

UUID(Universally Unique IDentifier)는 네트워크상에서 각 개체들을 식별하고 구별하기 위한 범용적 식별자이다. 고유성을 완벽하게 보장할수는 없지만 중복될 가능성이 거의 없다고 인정하여 많이 사용하고 있다. 


WMIC (Windows Management Instrumentation Command-line)을 이용하여

윈도우 시스템 UUID를 확인할 수 있다.


Win + R > cmd

wmic csproduct get uuid


이외에도 wmic를 이용하여 다음과 같은 정보를 얻을 수 있다.


wmic bios get biosversion           // bios 버전

wmic bios get serialnumber        // bios 시리얼 넘버

wmic diskdrive get index,serialnumber    // 디스크 시리얼 넘버



2020년 2월 25일 화요일

[DB] query example - insert, delete, update, select

데이터 추가( INSERT )
INSERT INTO table_name( col1, col2, ... ) VALUES ( val1, val2, ... );

데이터 삭제( DELETE )
DELETE FROM table_name WHERE col1=val1;

데이터 수정( UPDATE )
UPDATE table_name SET col1=val1 WHERE col_2=val2;

데이터 검색( SELECT )
SELECT col1 FROM table_name WHERE col2=val2;
SELECT col1 FROM table_name WHERE col2=val2 ORDER BY col3 DESC;  // 내림차순
SELECT col1 FROM table_name WHERE col2=val2 ORDER BY col3 ASC;   // 오름차순
SELECT col1 FROM table_name WHERE col2=val2 ORDER BY col3 LIMIT 3;   // 0번째 부터 3개
SELECT col1 FROM table_name WHERE col2=val2 ORDER BY col3 LIMIT 4, 3;   // 5번째 부터 3개

2019년 12월 10일 화요일

[Java] List vs ArrayList

List 는 인터페이스, ArrayList는 List를 상속받은 클래스이다.

도형에 비유한다면 List는 도형, ArrayList는 도형을 상속받은 정사각형이다.

List a = new ArrayList();
  -> 도형 a = new 정사각형();

ArrayList a = new ArrayList();
  -> 정사각형 a = new 정사각형();


2019년 9월 21일 토요일

[Java] HexString to Byte, Byte to HexString

HexString to Byte, Byte to HexString 변환 예제 이다.


public static byte[] hexStringToByte(String hex){
 if (hex == null || hex.length() == 0)
  return null;
  
 if( hex.length() % 2 != 0 )
  hex = "0" + hex;

 byte[] ba = new byte[hex.length() / 2];
 for (int i = 0; i < ba.length; i++)
  ba[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16);

 return ba;
}

public static String byteToHexString(byte[] bytes) {
 char[] container = new char[bytes.length * 2];

 for (int i = 0; i < bytes.length; i++) {
  int b = bytes[i] & 0xFF;
  container[i * 2] = Character.forDigit(b >>> 4, 0x10);
  container[i * 2 + 1] = Character.forDigit(b & 0xF, 0x10);
 }

 return new String(container);
}


[Java] 시간 출력하기 - SimpleDateFormat

SimpleDateFormat을 이용하여 시간을 원하는 포멧으로 출력할 수 있다.

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.KOREA);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.KOREA);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH", Locale.KOREA);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.KOREA);

// if need UTC
format.setTimeZone(TimeZone.getTimeZone("UTC"));

String time = format.format( new Date() );

2019년 9월 20일 금요일

[Java] String to byte, byte to String

맨날 햇갈려서 적어둡니다.

// String to byte
String string = "abcd";
byte[] byteArray;

byteArray = string.getBytes();
byteArray = string.getBytes("UTF-8");
byteArray = string.getBytes(StandardCharsets.UTF_8);

// byte to String
byte[] byteArray = { 'a', 'b', 'c', 'd' };
String string;

string = new String( byteArray );
string = new String( byteArray, "UTF-8" );
string = new String( byteArray, 0, byteArray.length, "UTF-8" );
string = new String( byteArray, StandardCharsets.UTF_8 );
string = new String( byteArray, 0, byteArray.length, StandardCharsets.UTF_8 );


2019년 9월 19일 목요일

[네트워크] directed broadcast and limited broadcast


네트워크를 하며 broadcast는 누구나 한번 쯤 들어보았을것이다.
네트워크 상의 모든 호스트들에게 패킷을 보내는 과정이다.
라디오 전파처럼 특정 대상에게 보내는것이 아닌 모드사람에게 뿌리는것을 의미한다.

ARP(Address Resolution Protocol), DHCP(Dynamic Host Configuration Protocol) 등에서 사용하고있다.

broadcast는 directed broadcast와 limited broadcast로 나뉜다.

limited broadcast는 로컬 네트워크 내의 호스트들에게 보내는 경우에 사용한다.
이 경우 주소를 255.255.255.255로 사용한다.
해당 네트워크의 라우터는 이 패킷을 외부 네트워크로 보내지 않는다.

directed broadcast는 네트워크 밖에서 특정 네트워크의 호스트들에게 보내는 경우에 사용한다.
이 경우 주소를 111.111.1.255로 사용한다.
라우터에 따라 no ip directed-broadcast 옵션이 되어있는 경우가 있다. 이는 스머프(Smurf) 공격을 막기위한 설정이다.
directed broadcast를 이용한 DoS(Denial of Service)공격을 스머프(Smurf) 공격이라고 한다.