Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping sensitive files in M365 environment #90

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c8e406d
first draft of oversharing.py
Dec 8, 2024
a87a9b4
updated code
Dec 8, 2024
ba32011
trying websocket
Dec 10, 2024
c2637d9
connection working
Dec 10, 2024
8fe0ba1
discovery and extract data first draft
Dec 19, 2024
8e3edc9
updated with regex parsing
Dec 26, 2024
e761859
Delete src/powerpwn/copilot/oversharing/response.json
zen-ayush Dec 29, 2024
672f923
Delete src/powerpwn/copilot/oversharing/pii
zen-ayush Dec 29, 2024
d807369
Delete src/powerpwn/copilot/oversharing/attempt.py
zen-ayush Dec 29, 2024
9618adc
updated questions
Dec 29, 2024
ebb5cb5
Merge branch 'ayush-llmoversharing' of https://github.com/zen-ayush/p…
Dec 29, 2024
910b59c
lint attempt
Dec 29, 2024
862ae01
isort and black
Dec 29, 2024
f5e5320
added runners and arguments
Dec 31, 2024
784b8a6
runnable modules
Dec 31, 2024
16746a3
updated parser to work
Jan 1, 2025
c07085a
headless browser
Jan 1, 2025
cbff871
fixed parser
Jan 4, 2025
067a376
Delete src/powerpwn/copilot_studio/final_results/chat_exists_output.txt
zen-ayush Jan 4, 2025
77f0277
finalized runners
Jan 14, 2025
99156d3
Merge branch 'ayush-llmoversharing' of https://github.com/zen-ayush/p…
Jan 14, 2025
ab3e814
black formatting
Jan 14, 2025
b5f06fe
run isort
Jan 14, 2025
3730fca
reformatting
Jan 14, 2025
696a74d
Merge branch 'main' into ayush-llmoversharing
zen-ayush Jan 14, 2025
3ac064d
reformatted
Jan 14, 2025
7e1c7db
reformat
Jan 14, 2025
eca9e61
Merge branch 'ayush-llmoversharing' of https://github.com/zen-ayush/p…
Jan 14, 2025
0db9074
attempting to fix
Jan 14, 2025
54d3727
added back chat exists output
Jan 15, 2025
51d681a
improvement to check for connection
Jan 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions puppeteer_get_substrate_bearer/get_substrate_bearer_office.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,23 @@ function delay(time) {
// Retrieve the value of 'secret' from local storage if the key's value includes a reference to 'https://substrate.office.com/sydney/.default'
// This is the bearer token for the Substrate API (also seen in the network tab WS under the access_token parameter)
const secretValue = await page.evaluate(() => {
const key = Object.keys(localStorage).find(k => {
const value = localStorage.getItem(k);
return value.includes('https://substrate.office.com/sydney/.default');
});
// Find the key with the specific URL pattern
const key = Object.keys(localStorage).find(k => {
const value = localStorage.getItem(k);
return k.includes('https://substrate.office.com/sydney/.default');
});

if (key) {
const data = JSON.parse(localStorage.getItem(key)); // Parse the JSON string
return data.secret; // Return the 'secret' (bearer token)
}

print("Not found")
return null; // If not found, return null

if (key) {
const data = JSON.parse(localStorage.getItem(key));
return data.secret;
}
return null;
});


// Print the bearer token to the console (change this to save it to a file or a secure location)
console.log('access_token:%s', secretValue);

Expand Down
5 changes: 5 additions & 0 deletions src/powerpwn/cli/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ def module_copilot(command_subparsers: argparse.ArgumentParser):
copilot_modules(whoami)
whoami.add_argument("-g", "--gui", action="store_true", help="Run local server for gui.")

discovery = copilot_subparsers.add_parser(
"discovery", description="Get the sensitive files that user has access to", help="Get the current user's information"
)
copilot_modules(discovery)

dump = copilot_subparsers.add_parser(
"dump",
description="Data dump using recon from whoami command",
Expand Down
5 changes: 4 additions & 1 deletion src/powerpwn/cli/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from powerpwn.copilot.gui.gui import Gui as CopilotGui
from powerpwn.copilot.interactive_chat.interactive_chat import InteractiveChat
from powerpwn.copilot.models.chat_argument import ChatArguments
from powerpwn.copilot.oversharing.discovery import Discovery
from powerpwn.copilot.spearphishing.automated_spear_phisher import AutomatedSpearPhisher
from powerpwn.copilot.whoami.whoami import WhoAmI
from powerpwn.copilot_studio.modules.deep_scan import DeepScan
Expand Down Expand Up @@ -204,13 +205,15 @@ def run_copilot_chat_command(args):
if args.gui:
CopilotGui().run(output_dir)
return

elif args.copilot_subcommand == "dump":
dump = Dump(parsed_args, args.directory)
output_dir = dump.run()
if args.gui:
CopilotGui().run(output_dir)
return
elif args.copilot_subcommand == "discovery":
Discovery(parsed_args).run()
return

raise NotImplementedError(f"Copilot {args.copilot_subcommand} subcommand has not been implemented yet.")

Expand Down
9 changes: 8 additions & 1 deletion src/powerpwn/copilot/copilot_connector/copilot_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,19 @@ def __get_plugins(self, access_token: str) -> list:
return plugins

def __get_conversation_parameters(self, refresh: bool = False) -> ConversationParameters:
print("hi")
print("Getting bearer token...")
access_token = self.__get_access_token(refresh)
if not access_token:
print("Failed to get bearer token. Exiting...")
raise CopilotConnectionFailedException("Could not get access token to connect to copilot.")

print(f"Access token: {access_token}")
token_parts = access_token.split('.')
if len(token_parts) != 3:
print(f"Invalid JWT format. Expected 3 segments, got {len(token_parts)}.")
raise ValueError(f"Invalid JWT format: {access_token}")

parsed_jwt = jwt.decode(access_token, algorithms=["RS256"], options={"verify_signature": False})
upn = parsed_jwt.get("upn")
unique_name = parsed_jwt.get("unique_name")
Expand All @@ -365,7 +372,7 @@ def __get_conversation_parameters(self, refresh: bool = False) -> ConversationPa
url = self.__get_websocket_url(access_token, self.__arguments.scenario, parsed_jwt)
session_id = self.__get_session_from_url(url)

available_plugins: list[PluginInfo] = self.__get_plugins(access_token)
available_plugins: list[PluginInfo] = []

return ConversationParameters(
conversation_id=str(uuid.uuid4()), url=url, session_id=session_id, available_plugins=available_plugins, used_plugins=[]
Expand Down
23 changes: 23 additions & 0 deletions src/powerpwn/copilot/oversharing/connectionverifier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import asyncio

from powerpwn.copilot.models.chat_argument import ChatArguments
from powerpwn.copilot.chat_automator.chat_automator import ChatAutomator
from powerpwn.copilot.copilot_connector.copilot_connector import CopilotConnector
from powerpwn.copilot.enums.copilot_scenario_enum import CopilotScenarioEnum
from powerpwn.copilot.enums.verbose_enum import VerboseEnum

args = ChatArguments(
user="[email protected]",
password="U*S+#XL)cw?d,7AQ",
verbose=VerboseEnum.full,
scenario=CopilotScenarioEnum.officeweb,
use_cached_access_token=False
)

chat_automator = ChatAutomator(args)

# init connector
chat_automator.init_connector()

# send prompt and get the answer as WebSocket message
result = chat_automator.send_prompt("Hello World")
Loading
Loading