728x90

iMessage ๊ตฌ์กฐ

 Macbook์— iphone iMessage๋ฅผ ๋™๊ธฐํ™”ํ•˜๋ฉด ~/Users/Name/Library/Messages ํด๋”์— ์ €์žฅ๋œ๋‹ค. ์ €์žฅ๋œ ํด๋”๋ฅผ ๋ณด๋ฉด .db๋กœ ๊ด€๋ฆฌ๋˜๋Š” ๊ฒƒ์„ ๋ณผ์ˆ˜์žˆ๋‹ค. sqlite๋กœ ์ €์žฅ๋˜๋ฉฐ ๋‹ค์–‘ํ•œ ์ปฌ๋Ÿผ๋“ค์ด ์žˆ๋‹ค. 

chat.db

 

 ์ฃผ์š” ํ…Œ์ด๋ธ”์€ message๋กœ text์™€ attributedBody์—์„œ ๋ฉ”์„ธ์ง€ ๋ณธ๋ฌธ์„ ์ฐพ์„ ์ˆ˜ ์žˆ๋‹ค. 

๋”๋ณด๊ธฐ

- **ROWID**: ๊ฐ ํ–‰(row)์˜ ๊ณ ์œ  ์‹๋ณ„์ž.
- **guid**: ๋ฉ”์‹œ์ง€์˜ ์ „์—ญ ๊ณ ์œ  ์‹๋ณ„์ž.
- **text**: ๋ฉ”์‹œ์ง€์˜ ๋‚ด์šฉ.
- **replace**: ๋Œ€์ฒด ํ…์ŠคํŠธ.
- **service_center**: ๋ฉ”์‹œ์ง€๋ฅผ ์ฒ˜๋ฆฌํ•œ ์„œ๋น„์Šค ์„ผํ„ฐ.
- **handle_id**: ๋ฉ”์‹œ์ง€์˜ ์†ก์‹ ์ž ๋˜๋Š” ์ˆ˜์‹ ์ž์˜ ID.
- **subject**: ๋ฉ”์‹œ์ง€์˜ ์ฃผ์ œ.
- **country**: ๋ฉ”์‹œ์ง€๊ฐ€ ๋ฐœ์†ก๋œ ๊ตญ๊ฐ€.
- **attributedBody**: ์†์„ฑ์ด ๋ถ€์—ฌ๋œ ๋ฉ”์‹œ์ง€ ๋ณธ๋ฌธ.
- **version**: ๋ฉ”์‹œ์ง€์˜ ๋ฒ„์ „.
- **type**: ๋ฉ”์‹œ์ง€ ์œ ํ˜•.
- **service**: ๋ฉ”์‹œ์ง€๊ฐ€ ์ „์†ก๋œ ์„œ๋น„์Šค (iMessage, SMS ๋“ฑ).
- **account**: ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ธ ๊ณ„์ •.
- **account_guid**: ๊ณ„์ •์˜ ์ „์—ญ ๊ณ ์œ  ์‹๋ณ„์ž.
- **error**: ๋ฉ”์‹œ์ง€ ์ „์†ก ์˜ค๋ฅ˜ ์—ฌ๋ถ€.
- **date**: ๋ฉ”์‹œ์ง€๊ฐ€ ์ „์†ก๋œ ๋‚ ์งœ.
- **date_read**: ๋ฉ”์‹œ์ง€๊ฐ€ ์ฝํžŒ ๋‚ ์งœ.
- **date_delivered**: ๋ฉ”์‹œ์ง€๊ฐ€ ์ „๋‹ฌ๋œ ๋‚ ์งœ.
- **is_delivered**: ๋ฉ”์‹œ์ง€๊ฐ€ ์ „๋‹ฌ๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **is_finished**: ๋ฉ”์‹œ์ง€ ์ „์†ก์ด ์™„๋ฃŒ๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **is_emote**: ์ด๋ชจํ‹ฐ์ฝ˜ ๋ฉ”์‹œ์ง€์ธ์ง€ ์—ฌ๋ถ€.
- **is_from_me**: ๋ฉ”์‹œ์ง€๊ฐ€ ๋‚˜์—๊ฒŒ์„œ ๋ณด๋‚ธ ๊ฒƒ์ธ์ง€ ์—ฌ๋ถ€.
- **is_empty**: ๋ฉ”์‹œ์ง€ ๋‚ด์šฉ์ด ๋น„์–ด ์žˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **is_delayed**: ๋ฉ”์‹œ์ง€๊ฐ€ ์ง€์—ฐ๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **is_auto_reply**: ์ž๋™ ์‘๋‹ต ๋ฉ”์‹œ์ง€์ธ์ง€ ์—ฌ๋ถ€.
- **is_prepared**: ๋ฉ”์‹œ์ง€๊ฐ€ ์ค€๋น„๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **is_read**: ๋ฉ”์‹œ์ง€๊ฐ€ ์ฝํ˜”๋Š”์ง€ ์—ฌ๋ถ€.
- **is_system_message**: ์‹œ์Šคํ…œ ๋ฉ”์‹œ์ง€์ธ์ง€ ์—ฌ๋ถ€.
- **is_sent**: ๋ฉ”์‹œ์ง€๊ฐ€ ๋ฐœ์†ก๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **has_dd_results**: ๋ฐ์ดํ„ฐ ํƒ์ง€ ๊ฒฐ๊ณผ๊ฐ€ ์žˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **is_service_message**: ์„œ๋น„์Šค ๋ฉ”์‹œ์ง€์ธ์ง€ ์—ฌ๋ถ€.
- **is_forward**: ๋ฉ”์‹œ์ง€๊ฐ€ ์ „๋‹ฌ๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **was_downgraded**: ๋ฉ”์‹œ์ง€๊ฐ€ ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œ ๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **is_archive**: ๋ฉ”์‹œ์ง€๊ฐ€ ์•„์นด์ด๋ธŒ๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **cache_has_attachments**: ๋ฉ”์‹œ์ง€์— ์ฒจ๋ถ€ ํŒŒ์ผ์ด ์žˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **cache_roomnames**: ์บ์‹œ๋œ ๋ฐฉ ์ด๋ฆ„.
- **was_data_detected**: ๋ฐ์ดํ„ฐ๊ฐ€ ํƒ์ง€๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **was_deduplicated**: ์ค‘๋ณต ์ œ๊ฑฐ๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **is_audio_message**: ์˜ค๋””์˜ค ๋ฉ”์‹œ์ง€์ธ์ง€ ์—ฌ๋ถ€.
- **is_played**: ๋ฉ”์‹œ์ง€๊ฐ€ ์žฌ์ƒ๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **date_played**: ๋ฉ”์‹œ์ง€๊ฐ€ ์žฌ์ƒ๋œ ๋‚ ์งœ.
- **item_type**: ํ•ญ๋ชฉ ์œ ํ˜•.
- **other_handle**: ๋‹ค๋ฅธ ํ•ธ๋“ค.
- **group_title**: ๊ทธ๋ฃน ์ œ๋ชฉ.
- **group_action_type**: ๊ทธ๋ฃน ์ž‘์—… ์œ ํ˜•.
- **share_status**: ๊ณต์œ  ์ƒํƒœ.
- **share_direction**: ๊ณต์œ  ๋ฐฉํ–ฅ.
- **is_expirable**: ๋งŒ๋ฃŒ๋˜๋Š”์ง€ ์—ฌ๋ถ€.
- **expire_state**: ๋งŒ๋ฃŒ ์ƒํƒœ.
- **message_action_type**: ๋ฉ”์‹œ์ง€ ์ž‘์—… ์œ ํ˜•.
- **message_source**: ๋ฉ”์‹œ์ง€ ์ถœ์ฒ˜.
- **associated_message_guid**: ์—ฐ๊ด€๋œ ๋ฉ”์‹œ์ง€์˜ ์ „์—ญ ๊ณ ์œ  ์‹๋ณ„์ž.
- **associated_message_type**: ์—ฐ๊ด€๋œ ๋ฉ”์‹œ์ง€ ์œ ํ˜•.
- **balloon_bundle_id**: ํ’์„  ๋ฒˆ๋“ค ID.
- **payload_data**: ํŽ˜์ด๋กœ๋“œ ๋ฐ์ดํ„ฐ.
- **expressive_send_style_id**: ํ‘œํ˜„์‹ ์ „์†ก ์Šคํƒ€์ผ ID.
- **associated_message_range_location**: ์—ฐ๊ด€๋œ ๋ฉ”์‹œ์ง€ ๋ฒ”์œ„ ์œ„์น˜.
- **associated_message_range_length**: ์—ฐ๊ด€๋œ ๋ฉ”์‹œ์ง€ ๋ฒ”์œ„ ๊ธธ์ด.
- **time_expressive_send_played**: ํ‘œํ˜„์‹ ์ „์†ก ์žฌ์ƒ ์‹œ๊ฐ„.
- **message_summary_info**: ๋ฉ”์‹œ์ง€ ์š”์•ฝ ์ •๋ณด.
- **ck_sync_state**: ํด๋ผ์šฐ๋“œ ํ‚คํŠธ ๋™๊ธฐํ™” ์ƒํƒœ.
- **ck_record_id**: ํด๋ผ์šฐ๋“œ ํ‚คํŠธ ๋ ˆ์ฝ”๋“œ ID.
- **ck_record_change_tag**: ํด๋ผ์šฐ๋“œ ํ‚คํŠธ ๋ ˆ์ฝ”๋“œ ๋ณ€๊ฒฝ ํƒœ๊ทธ.
- **destination_caller_id**: ๋Œ€์ƒ ๋ฐœ์‹ ์ž ID.
- **is_corrupt**: ์†์ƒ๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **reply_to_guid**: ํšŒ์‹ ํ•  ๋ฉ”์‹œ์ง€์˜ ์ „์—ญ ๊ณ ์œ  ์‹๋ณ„์ž.
- **sort_id**: ์ •๋ ฌ ID.
- **is_spam**: ์ŠคํŒธ ๋ฉ”์‹œ์ง€์ธ์ง€ ์—ฌ๋ถ€.
- **has_unseen_mention**: ๋ณด์ง€ ์•Š์€ ๋ฉ˜์…˜์ด ์žˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **thread_originator_guid**: ์Šค๋ ˆ๋“œ ์‹œ์ž‘์ž์˜ ์ „์—ญ ๊ณ ์œ  ์‹๋ณ„์ž.
- **thread_originator_part**: ์Šค๋ ˆ๋“œ ์‹œ์ž‘์ž์˜ ๋ถ€๋ถ„.
- **syndication_ranges**: ๋ฐฐํฌ ๋ฒ”์œ„.
- **synced_syndication_ranges**: ๋™๊ธฐํ™”๋œ ๋ฐฐํฌ ๋ฒ”์œ„.
- **was_delivered_quietly**: ์กฐ์šฉํžˆ ์ „๋‹ฌ๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **did_notify_recipient**: ์ˆ˜์‹ ์ž๊ฐ€ ์•Œ๋ฆผ์„ ๋ฐ›์•˜๋Š”์ง€ ์—ฌ๋ถ€.
- **date_retracted**: ์ฒ ํšŒ๋œ ๋‚ ์งœ.
- **date_edited**: ํŽธ์ง‘๋œ ๋‚ ์งœ.
- **was_detonated**: ํญํŒŒ๋˜์—ˆ๋Š”์ง€ ์—ฌ๋ถ€.
- **part_count**: ํŒŒํŠธ ์ˆ˜.
- **is_stewie**: ์ŠคํŠœ์ด ์ƒํƒœ์ธ์ง€ ์—ฌ๋ถ€.
- **is_kt_verified**: KT ์ธ์ฆ ์—ฌ๋ถ€.
- **is_sos**: ๊ธด๊ธ‰ ๋ฉ”์‹œ์ง€์ธ์ง€ ์—ฌ๋ถ€.
- **is_critical**: ์ค‘์š” ๋ฉ”์‹œ์ง€์ธ์ง€ ์—ฌ๋ถ€.
- **bia_reference_id**: BIA ์ฐธ์กฐ ID.
- **fallback_hash**: ํด๋ฐฑ ํ•ด์‹œ.
- **date_uct**: UCT ๋‚ ์งœ.

 

  Python์œผ๋กœ ๋ฐ์ดํ„ฐ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

 ๋จผ์ € ~/Users/Name/Library/Messages์— ์ ‘๊ทผํ•˜๋ ค๋ฉด ์ ‘๊ทผ ๊ถŒํ•œ์ด ํ•„์š”ํ•˜๋‹ค. ๊ตฌ๋™ํ•˜๋ ค๋Š” python์˜ ์‹คํ–‰ํ™˜๊ฒฝ์— ๋งž์ถฐ 

๊ฐœ์ธ์ •๋ณด ๋ณดํ˜ธ ๋ฐ ๋ณด์•ˆ > ์ „์ฒด ๋””์Šคํฌ ์ ‘๊ทผ ๊ถŒํ•œ์—์„œ ํ„ฐ๋ฏธ๋„๊ณผ Vscode๋ฅผ ํ™œ์„ฑํ™” ์‹œ์ผœ์ค€๋‹ค. 

 

Mac Settings

 

 ๋‹ค์Œ์œผ๋กœ python์—์„œ sqlite๋กœ Message db๋ฅผ ๋ถˆ๋Ÿฌ์˜จ๋‹ค.

import sqlite3
import pandas as pd

path = "/Users/Name/Library/Messages/chat.db"

# substitute username with your username
conn = sqlite3.connect(path)
# connect to the database
cur = conn.cursor()
# get the names of the tables in the database

# get the 10 entries of the message table using pandas
messages = pd.read_sql_query("select * from message order by date desc limit 10", conn)

# messages['attributedBody']
# b'\x04\x0bstreamtyped\x81\xe8\x03\x84\x01@\x84

 

 ๋ถˆ๋Ÿฌ์˜จ message๋ฅผ ๋ณด๋ฉด Web ๋ฐœ์‹ ์œผ๋กœ ์˜จ ๋ฌธ์ž๋“ค ๋Œ€๋ถ€๋ถ„์ด encode ๋˜์–ด ์žˆ์–ด ํ™•์ธ์ด ์–ด๋ ต๋‹ค. attributedBody๋ฅผ decode ํ•ด์„œ ๋ฌธ์ž๋ฅผ ํ™•์ธํ•œ๋‹ค.

def decode_message(row):
  msg_text = row['text']
  msg_attributed_body = row['attributedBody']

  # Logic from https://github.com/my-other-github-account/imessage_tools
  body=''
  if msg_text:
    body = msg_text
  elif msg_attributed_body is None:
    body = ''
  else:
    try:
      msg_attributed_body = msg_attributed_body.decode('utf-8', errors='replace')
    except AttributeError as err:
      pass

    if "NSNumber" in str(msg_attributed_body):
      msg_attributed_body = str(msg_attributed_body).split("NSNumber")[0]
      if "NSString" in msg_attributed_body:
        msg_attributed_body = str(msg_attributed_body).split("NSString")[1]
        if "NSDictionary" in msg_attributed_body:
          msg_attributed_body = str(msg_attributed_body).split("NSDictionary")[0]
          msg_attributed_body = msg_attributed_body[6:-12]
          body = msg_attributed_body
  return body
  
print(decode_message(messages.iloc[0]))

# [Web๋ฐœ์‹ ]
# ๋„ค์ด๋ฒ„ ํ˜„๋Œ€์นด๋“œ ์Šน์ธ
# *
# 13,000์› ์ผ์‹œ๋ถˆ
# 06/15 13:49
# -----
# ๋ˆ„์ 108,108,128,328,108,420์›

 

 Mac๊ณผ Iphone์„ ๊ฐ™์ด ์‚ฌ์šฉํ•˜๋Š” ์‚ฌ๋žŒ์€ ์œ„ ๋ช‡์ค„ ์ฝ”๋“œ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๋ถˆ๋Ÿฌ์™€ LLM์œผ๋กœ ์—ฌ๋Ÿฌ๊ฐ€์ง€๋ฅผ ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋‹ค์Œ ํ”„๋กœ์ ํŠธ๋กœ ~ 

๋ฐ˜์‘ํ˜•
๋‹คํ–ˆ๋‹ค