'도산공원'에 해당되는 글 4건

  1. 2024.08.08 ssh 터널링 -D
  2. 2024.07.08 ssh 터널링 L
  3. 2024.07.08 ssh 터널링 R
  4. 2015.08.16 12

ssh 터널링 -D

도산공원 2024. 8. 8. 00:56

-D 옵션으로 socks proxy 사용하기
A라는 서버에서 B라는 서버에 있는 서비스를 보려고 합니다. 이 때, 해당 웹 어플리케이션은 B에서만 연결된 특정 IP로 통신을 하고 있고, 이 때문에 A에서 어플케이션이 제대로 동작하지 않는 상황입니다.

이 때 사용할 수 있는 것이 -D 옵션입니다.

예시

ssh -D 12345 user@server.com
해당 세션이 꺼져있지 않은 상태에서 A 서버에서 웹 브라우저가 localhost:12345를 프록시로 사용하도록 하면 해당 웹 어플리케이션이 제대로 동작합니다.

만약 windows라면 다음과 같이 진행하면 socks proxy를 사용하도록 할 수 있습니다. CMD를 열고 다음과 같이 입력하면 새로운 창으로 chrome이 뜰 것입니다.

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir="%USERPROFILE%\proxy-profile" --proxy-server="socks5://localhost:12345"
해당 창에서 어플리케이션을 실행하면 실제 B 서버의 desktop에서 동작하는 것과 같은 효과를 볼 수 있습니다.

'도산공원' 카테고리의 다른 글

ssh 터널링 L  (0) 2024.07.08
ssh 터널링 R  (0) 2024.07.08
12  (0) 2015.08.16
Posted by wakira
,

ssh 터널링 L

도산공원 2024. 7. 8. 01:03

ssh -fN -L 80:192.168.0.10:80 -l {user_account} {remote_machine}

ssh -fN -L {로컬에서 접속할 포트}:{목표 서버 ip}:{목표 서버 포트} -l {경유지 계정} {경유지 ip}

 

ex) ssh -fN -L 5333:10.220.176.71:5444 -l root 14.63.145.145 ==> postgrel가 설치되어있는 10.220.176.71:5444로 접속이 불가능 했다. 그래서 DB 서버와 연결가능한 다른 서버 14.63.145.145를 경유해서 터널링을 시도. root 계정의 비번을 입력후 , 내 로컬pc에서 5333포트로 접속을 하니 DB서버 연결 가능. 
-f : Requests ssh to go to background just before command execution.
-N : Do not execute a remote command. This is useful for just forwarding ports.

'도산공원' 카테고리의 다른 글

ssh 터널링 -D  (0) 2024.08.08
ssh 터널링 R  (0) 2024.07.08
12  (0) 2015.08.16
Posted by wakira
,

ssh 터널링 R

도산공원 2024. 7. 8. 00:55

ssh -Nf -R  0.0.0.0:1234:127.0.0.1:5678 id@ip -p port
ssh -fN -R 0.0.0.0:1234:127.0.0.1:3389 a@b.c.d -p 21111


ip주소의 1234포트로 접속하면
위 커맨드실행한 컴퓨터 5678포트로 접속한다
-f : Requests ssh to go to background just before command execution.
-N : Do not execute a remote command. This is useful for just forwarding ports.

'도산공원' 카테고리의 다른 글

ssh 터널링 -D  (0) 2024.08.08
ssh 터널링 L  (0) 2024.07.08
12  (0) 2015.08.16
Posted by wakira
,

12

도산공원 2015. 8. 16. 19:33

http://lee70.blogspot.kr/2014/01/blog-post.html

안드로이드 스크린샷(화면 캡쳐하기 (코드에서))

package com.example.activity_shot;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {
 Activity av=MainActivity.this;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  Button button = (Button) findViewById(R.id.button1);
        button.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View arg0) {
    try {
     screenshot(av);
    } catch (Exception e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
  
   }
        }); 
 }

 public void screenshot(Activity av2)throws Exception { 
  View view = av2.getWindow().getDecorView();

  view.setDrawingCacheEnabled(true);

  Bitmap screenshot = view.getDrawingCache();
       //Activity.getWindow().getDecorView()

  String filename = "screenshot.png";

  try {

  File f = new File(Environment.getExternalStorageDirectory(), filename);

  f.createNewFile();

  OutputStream outStream = new FileOutputStream(f);

  screenshot.compress(Bitmap.CompressFormat.PNG, 100, outStream);

  outStream.close();

  } catch (IOException e) {

  e.printStackTrace();

  }

  view.setDrawingCacheEnabled(false);

  }

}






http://stackoverflow.com/questions/4396059/how-to-simulate-a-touch-event-in-android

view.setOnTouchListener(new OnTouchListener()
{
    public boolean onTouch(View v, MotionEvent event)
    {
        Toast toast = Toast.makeText(
            getApplicationContext(), 
            "View touched", 
            Toast.LENGTH_LONG
        );
        toast.show();

        return true;
    }
});


// Obtain MotionEvent object
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis() + 100;
float x = 0.0f;
float y = 0.0f;
// List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState()
int metaState = 0;
MotionEvent motionEvent = MotionEvent.obtain(
    downTime, 
    eventTime, 
    MotionEvent.ACTION_UP, 
    x, 
    y, 
    metaState
);

// Dispatch touch event to view
view.dispatchTouchEvent(motionEvent);


'도산공원' 카테고리의 다른 글

ssh 터널링 -D  (0) 2024.08.08
ssh 터널링 L  (0) 2024.07.08
ssh 터널링 R  (0) 2024.07.08
Posted by wakira
,